diff options
156 files changed, 7584 insertions, 5523 deletions
diff --git a/Documentation/DocBook/media/v4l/biblio.xml b/Documentation/DocBook/media/v4l/biblio.xml index 7c49facecd25..1078e45f189f 100644 --- a/Documentation/DocBook/media/v4l/biblio.xml +++ b/Documentation/DocBook/media/v4l/biblio.xml | |||
@@ -194,7 +194,7 @@ in the frequency range from 87,5 to 108,0 MHz</title> | |||
194 | <corpauthor>National Radio Systems Committee | 194 | <corpauthor>National Radio Systems Committee |
195 | (<ulink url="http://www.nrscstandards.org">http://www.nrscstandards.org</ulink>)</corpauthor> | 195 | (<ulink url="http://www.nrscstandards.org">http://www.nrscstandards.org</ulink>)</corpauthor> |
196 | </authorgroup> | 196 | </authorgroup> |
197 | <title>NTSC-4: United States RBDS Standard</title> | 197 | <title>NRSC-4: United States RBDS Standard</title> |
198 | </biblioentry> | 198 | </biblioentry> |
199 | 199 | ||
200 | <biblioentry id="iso12232"> | 200 | <biblioentry id="iso12232"> |
diff --git a/Documentation/DocBook/media/v4l/common.xml b/Documentation/DocBook/media/v4l/common.xml index 4101aeb56540..b91d25313b63 100644 --- a/Documentation/DocBook/media/v4l/common.xml +++ b/Documentation/DocBook/media/v4l/common.xml | |||
@@ -464,14 +464,14 @@ The <structfield>type</structfield> field of the respective | |||
464 | <structfield>tuner</structfield> field contains the index number of | 464 | <structfield>tuner</structfield> field contains the index number of |
465 | the tuner.</para> | 465 | the tuner.</para> |
466 | 466 | ||
467 | <para>Radio devices have exactly one tuner with index zero, no | 467 | <para>Radio input devices have exactly one tuner with index zero, no |
468 | video inputs.</para> | 468 | video inputs.</para> |
469 | 469 | ||
470 | <para>To query and change tuner properties applications use the | 470 | <para>To query and change tuner properties applications use the |
471 | &VIDIOC-G-TUNER; and &VIDIOC-S-TUNER; ioctl, respectively. The | 471 | &VIDIOC-G-TUNER; and &VIDIOC-S-TUNER; ioctl, respectively. The |
472 | &v4l2-tuner; returned by <constant>VIDIOC_G_TUNER</constant> also | 472 | &v4l2-tuner; returned by <constant>VIDIOC_G_TUNER</constant> also |
473 | contains signal status information applicable when the tuner of the | 473 | contains signal status information applicable when the tuner of the |
474 | current video input, or a radio tuner is queried. Note that | 474 | current video or radio input is queried. Note that |
475 | <constant>VIDIOC_S_TUNER</constant> does not switch the current tuner, | 475 | <constant>VIDIOC_S_TUNER</constant> does not switch the current tuner, |
476 | when there is more than one at all. The tuner is solely determined by | 476 | when there is more than one at all. The tuner is solely determined by |
477 | the current video input. Drivers must support both ioctls and set the | 477 | the current video input. Drivers must support both ioctls and set the |
@@ -491,8 +491,17 @@ the modulator. The <structfield>type</structfield> field of the | |||
491 | respective &v4l2-output; returned by the &VIDIOC-ENUMOUTPUT; ioctl is | 491 | respective &v4l2-output; returned by the &VIDIOC-ENUMOUTPUT; ioctl is |
492 | set to <constant>V4L2_OUTPUT_TYPE_MODULATOR</constant> and its | 492 | set to <constant>V4L2_OUTPUT_TYPE_MODULATOR</constant> and its |
493 | <structfield>modulator</structfield> field contains the index number | 493 | <structfield>modulator</structfield> field contains the index number |
494 | of the modulator. This specification does not define radio output | 494 | of the modulator.</para> |
495 | devices.</para> | 495 | |
496 | <para>Radio output devices have exactly one modulator with index | ||
497 | zero, no video outputs.</para> | ||
498 | |||
499 | <para>A video or radio device cannot support both a tuner and a | ||
500 | modulator. Two separate device nodes will have to be used for such | ||
501 | hardware, one that supports the tuner functionality and one that supports | ||
502 | the modulator functionality. The reason is a limitation with the | ||
503 | &VIDIOC-S-FREQUENCY; ioctl where you cannot specify whether the frequency | ||
504 | is for a tuner or a modulator.</para> | ||
496 | 505 | ||
497 | <para>To query and change modulator properties applications use | 506 | <para>To query and change modulator properties applications use |
498 | the &VIDIOC-G-MODULATOR; and &VIDIOC-S-MODULATOR; ioctl. Note that | 507 | the &VIDIOC-G-MODULATOR; and &VIDIOC-S-MODULATOR; ioctl. Note that |
diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml index ea42ef824948..97b895151bb0 100644 --- a/Documentation/DocBook/media/v4l/compat.xml +++ b/Documentation/DocBook/media/v4l/compat.xml | |||
@@ -2377,10 +2377,11 @@ that used it. It was originally scheduled for removal in 2.6.35. | |||
2377 | <para>V4L2_CTRL_FLAG_VOLATILE was added to signal volatile controls to userspace.</para> | 2377 | <para>V4L2_CTRL_FLAG_VOLATILE was added to signal volatile controls to userspace.</para> |
2378 | </listitem> | 2378 | </listitem> |
2379 | <listitem> | 2379 | <listitem> |
2380 | <para>Add selection API for extended control over cropping and | 2380 | <para>Add selection API for extended control over cropping |
2381 | composing. Does not affect the compatibility of current drivers and | 2381 | and composing. Does not affect the compatibility of current |
2382 | applications. See <link linkend="selection-api"> selection API </link> for | 2382 | drivers and applications. See <link |
2383 | details.</para> | 2383 | linkend="selection-api"> selection API </link> for |
2384 | details.</para> | ||
2384 | </listitem> | 2385 | </listitem> |
2385 | </orderedlist> | 2386 | </orderedlist> |
2386 | </section> | 2387 | </section> |
@@ -2458,6 +2459,18 @@ details.</para> | |||
2458 | </orderedlist> | 2459 | </orderedlist> |
2459 | </section> | 2460 | </section> |
2460 | 2461 | ||
2462 | <section> | ||
2463 | <title>V4L2 in Linux 3.5</title> | ||
2464 | <orderedlist> | ||
2465 | <listitem> | ||
2466 | <para>Replaced <structfield>input</structfield> in | ||
2467 | <structname>v4l2_buffer</structname> by | ||
2468 | <structfield>reserved2</structfield> and removed | ||
2469 | <constant>V4L2_BUF_FLAG_INPUT</constant>.</para> | ||
2470 | </listitem> | ||
2471 | </orderedlist> | ||
2472 | </section> | ||
2473 | |||
2461 | <section id="other"> | 2474 | <section id="other"> |
2462 | <title>Relation of V4L2 to other Linux multimedia APIs</title> | 2475 | <title>Relation of V4L2 to other Linux multimedia APIs</title> |
2463 | 2476 | ||
diff --git a/Documentation/DocBook/media/v4l/dev-subdev.xml b/Documentation/DocBook/media/v4l/dev-subdev.xml index 4afcbbec5eda..a3d9dd093268 100644 --- a/Documentation/DocBook/media/v4l/dev-subdev.xml +++ b/Documentation/DocBook/media/v4l/dev-subdev.xml | |||
@@ -276,7 +276,7 @@ | |||
276 | </para> | 276 | </para> |
277 | </section> | 277 | </section> |
278 | 278 | ||
279 | <section> | 279 | <section id="v4l2-subdev-selections"> |
280 | <title>Selections: cropping, scaling and composition</title> | 280 | <title>Selections: cropping, scaling and composition</title> |
281 | 281 | ||
282 | <para>Many sub-devices support cropping frames on their input or output | 282 | <para>Many sub-devices support cropping frames on their input or output |
@@ -290,8 +290,8 @@ | |||
290 | size. Both the coordinates and sizes are expressed in pixels.</para> | 290 | size. Both the coordinates and sizes are expressed in pixels.</para> |
291 | 291 | ||
292 | <para>As for pad formats, drivers store try and active | 292 | <para>As for pad formats, drivers store try and active |
293 | rectangles for the selection targets of ACTUAL type <xref | 293 | rectangles for the selection targets <xref |
294 | linkend="v4l2-subdev-selection-targets">.</xref></para> | 294 | linkend="v4l2-selections-common" />.</para> |
295 | 295 | ||
296 | <para>On sink pads, cropping is applied relative to the | 296 | <para>On sink pads, cropping is applied relative to the |
297 | current pad format. The pad format represents the image size as | 297 | current pad format. The pad format represents the image size as |
@@ -308,7 +308,7 @@ | |||
308 | <para>Scaling support is optional. When supported by a subdev, | 308 | <para>Scaling support is optional. When supported by a subdev, |
309 | the crop rectangle on the subdev's sink pad is scaled to the | 309 | the crop rectangle on the subdev's sink pad is scaled to the |
310 | size configured using the &VIDIOC-SUBDEV-S-SELECTION; IOCTL | 310 | size configured using the &VIDIOC-SUBDEV-S-SELECTION; IOCTL |
311 | using <constant>V4L2_SUBDEV_SEL_COMPOSE_ACTUAL</constant> | 311 | using <constant>V4L2_SEL_TGT_COMPOSE</constant> |
312 | selection target on the same pad. If the subdev supports scaling | 312 | selection target on the same pad. If the subdev supports scaling |
313 | but not composing, the top and left values are not used and must | 313 | but not composing, the top and left values are not used and must |
314 | always be set to zero.</para> | 314 | always be set to zero.</para> |
@@ -323,32 +323,32 @@ | |||
323 | <para>The drivers should always use the closest possible | 323 | <para>The drivers should always use the closest possible |
324 | rectangle the user requests on all selection targets, unless | 324 | rectangle the user requests on all selection targets, unless |
325 | specifically told otherwise. | 325 | specifically told otherwise. |
326 | <constant>V4L2_SUBDEV_SEL_FLAG_SIZE_GE</constant> and | 326 | <constant>V4L2_SEL_FLAG_GE</constant> and |
327 | <constant>V4L2_SUBDEV_SEL_FLAG_SIZE_LE</constant> flags may be | 327 | <constant>V4L2_SEL_FLAG_LE</constant> flags may be |
328 | used to round the image size either up or down. <xref | 328 | used to round the image size either up or down. <xref |
329 | linkend="v4l2-subdev-selection-flags"></xref></para> | 329 | linkend="v4l2-selection-flags" /></para> |
330 | </section> | 330 | </section> |
331 | 331 | ||
332 | <section> | 332 | <section> |
333 | <title>Types of selection targets</title> | 333 | <title>Types of selection targets</title> |
334 | 334 | ||
335 | <section> | 335 | <section> |
336 | <title>ACTUAL targets</title> | 336 | <title>Actual targets</title> |
337 | 337 | ||
338 | <para>ACTUAL targets reflect the actual hardware configuration | 338 | <para>Actual targets (without a postfix) reflect the actual |
339 | at any point of time. There is a BOUNDS target | 339 | hardware configuration at any point of time. There is a BOUNDS |
340 | corresponding to every ACTUAL.</para> | 340 | target corresponding to every actual target.</para> |
341 | </section> | 341 | </section> |
342 | 342 | ||
343 | <section> | 343 | <section> |
344 | <title>BOUNDS targets</title> | 344 | <title>BOUNDS targets</title> |
345 | 345 | ||
346 | <para>BOUNDS targets is the smallest rectangle that contains | 346 | <para>BOUNDS targets is the smallest rectangle that contains all |
347 | all valid ACTUAL rectangles. It may not be possible to set the | 347 | valid actual rectangles. It may not be possible to set the actual |
348 | ACTUAL rectangle as large as the BOUNDS rectangle, however. | 348 | rectangle as large as the BOUNDS rectangle, however. This may be |
349 | This may be because e.g. a sensor's pixel array is not | 349 | because e.g. a sensor's pixel array is not rectangular but |
350 | rectangular but cross-shaped or round. The maximum size may | 350 | cross-shaped or round. The maximum size may also be smaller than the |
351 | also be smaller than the BOUNDS rectangle.</para> | 351 | BOUNDS rectangle.</para> |
352 | </section> | 352 | </section> |
353 | 353 | ||
354 | </section> | 354 | </section> |
@@ -362,7 +362,7 @@ | |||
362 | performed by the user: the changes made will be propagated to | 362 | performed by the user: the changes made will be propagated to |
363 | any subsequent stages. If this behaviour is not desired, the | 363 | any subsequent stages. If this behaviour is not desired, the |
364 | user must set | 364 | user must set |
365 | <constant>V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG</constant> flag. This | 365 | <constant>V4L2_SEL_FLAG_KEEP_CONFIG</constant> flag. This |
366 | flag causes no propagation of the changes are allowed in any | 366 | flag causes no propagation of the changes are allowed in any |
367 | circumstances. This may also cause the accessed rectangle to be | 367 | circumstances. This may also cause the accessed rectangle to be |
368 | adjusted by the driver, depending on the properties of the | 368 | adjusted by the driver, depending on the properties of the |
diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml index fd6aca2922b6..1885cc0755cb 100644 --- a/Documentation/DocBook/media/v4l/io.xml +++ b/Documentation/DocBook/media/v4l/io.xml | |||
@@ -683,14 +683,12 @@ memory, set by the application. See <xref linkend="userp" /> for details. | |||
683 | </row> | 683 | </row> |
684 | <row> | 684 | <row> |
685 | <entry>__u32</entry> | 685 | <entry>__u32</entry> |
686 | <entry><structfield>input</structfield></entry> | 686 | <entry><structfield>reserved2</structfield></entry> |
687 | <entry></entry> | 687 | <entry></entry> |
688 | <entry>Some video capture drivers support rapid and | 688 | <entry>A place holder for future extensions and custom |
689 | synchronous video input changes, a function useful for example in | 689 | (driver defined) buffer types |
690 | video surveillance applications. For this purpose applications set the | 690 | <constant>V4L2_BUF_TYPE_PRIVATE</constant> and higher. Applications |
691 | <constant>V4L2_BUF_FLAG_INPUT</constant> flag, and this field to the | 691 | should set this to 0.</entry> |
692 | number of a video input as in &v4l2-input; field | ||
693 | <structfield>index</structfield>.</entry> | ||
694 | </row> | 692 | </row> |
695 | <row> | 693 | <row> |
696 | <entry>__u32</entry> | 694 | <entry>__u32</entry> |
@@ -923,13 +921,6 @@ Drivers set or clear this flag when the <constant>VIDIOC_DQBUF</constant> | |||
923 | ioctl is called.</entry> | 921 | ioctl is called.</entry> |
924 | </row> | 922 | </row> |
925 | <row> | 923 | <row> |
926 | <entry><constant>V4L2_BUF_FLAG_INPUT</constant></entry> | ||
927 | <entry>0x0200</entry> | ||
928 | <entry>The <structfield>input</structfield> field is valid. | ||
929 | Applications set or clear this flag before calling the | ||
930 | <constant>VIDIOC_QBUF</constant> ioctl.</entry> | ||
931 | </row> | ||
932 | <row> | ||
933 | <entry><constant>V4L2_BUF_FLAG_PREPARED</constant></entry> | 924 | <entry><constant>V4L2_BUF_FLAG_PREPARED</constant></entry> |
934 | <entry>0x0400</entry> | 925 | <entry>0x0400</entry> |
935 | <entry>The buffer has been prepared for I/O and can be queued by the | 926 | <entry>The buffer has been prepared for I/O and can be queued by the |
diff --git a/Documentation/DocBook/media/v4l/selection-api.xml b/Documentation/DocBook/media/v4l/selection-api.xml index b299e4779354..e7ed5077834d 100644 --- a/Documentation/DocBook/media/v4l/selection-api.xml +++ b/Documentation/DocBook/media/v4l/selection-api.xml | |||
@@ -53,11 +53,11 @@ cropping and composing rectangles have the same size.</para> | |||
53 | </mediaobject> | 53 | </mediaobject> |
54 | </figure> | 54 | </figure> |
55 | 55 | ||
56 | For complete list of the available selection targets see table <xref | ||
57 | linkend="v4l2-sel-target"/> | ||
58 | |||
59 | </section> | 56 | </section> |
60 | 57 | ||
58 | See <xref linkend="v4l2-selection-targets" /> for more | ||
59 | information. | ||
60 | |||
61 | <section> | 61 | <section> |
62 | 62 | ||
63 | <title>Configuration</title> | 63 | <title>Configuration</title> |
@@ -74,7 +74,7 @@ cropping/composing rectangles may have to be aligned, and both the source and | |||
74 | the sink may have arbitrary upper and lower size limits. Therefore, as usual, | 74 | the sink may have arbitrary upper and lower size limits. Therefore, as usual, |
75 | drivers are expected to adjust the requested parameters and return the actual | 75 | drivers are expected to adjust the requested parameters and return the actual |
76 | values selected. An application can control the rounding behaviour using <link | 76 | values selected. An application can control the rounding behaviour using <link |
77 | linkend="v4l2-sel-flags"> constraint flags </link>.</para> | 77 | linkend="v4l2-selection-flags"> constraint flags </link>.</para> |
78 | 78 | ||
79 | <section> | 79 | <section> |
80 | 80 | ||
@@ -91,7 +91,7 @@ top/left corner at position <constant> (0,0) </constant>. The rectangle's | |||
91 | coordinates are expressed in pixels.</para> | 91 | coordinates are expressed in pixels.</para> |
92 | 92 | ||
93 | <para>The top left corner, width and height of the source rectangle, that is | 93 | <para>The top left corner, width and height of the source rectangle, that is |
94 | the area actually sampled, is given by the <constant> V4L2_SEL_TGT_CROP_ACTIVE | 94 | the area actually sampled, is given by the <constant> V4L2_SEL_TGT_CROP |
95 | </constant> target. It uses the same coordinate system as <constant> | 95 | </constant> target. It uses the same coordinate system as <constant> |
96 | V4L2_SEL_TGT_CROP_BOUNDS </constant>. The active cropping area must lie | 96 | V4L2_SEL_TGT_CROP_BOUNDS </constant>. The active cropping area must lie |
97 | completely inside the capture boundaries. The driver may further adjust the | 97 | completely inside the capture boundaries. The driver may further adjust the |
@@ -111,13 +111,13 @@ height are equal to the image size set by <constant> VIDIOC_S_FMT </constant>. | |||
111 | </para> | 111 | </para> |
112 | 112 | ||
113 | <para>The part of a buffer into which the image is inserted by the hardware is | 113 | <para>The part of a buffer into which the image is inserted by the hardware is |
114 | controlled by the <constant> V4L2_SEL_TGT_COMPOSE_ACTIVE </constant> target. | 114 | controlled by the <constant> V4L2_SEL_TGT_COMPOSE </constant> target. |
115 | The rectangle's coordinates are also expressed in the same coordinate system as | 115 | The rectangle's coordinates are also expressed in the same coordinate system as |
116 | the bounds rectangle. The composing rectangle must lie completely inside bounds | 116 | the bounds rectangle. The composing rectangle must lie completely inside bounds |
117 | rectangle. The driver must adjust the composing rectangle to fit to the | 117 | rectangle. The driver must adjust the composing rectangle to fit to the |
118 | bounding limits. Moreover, the driver can perform other adjustments according | 118 | bounding limits. Moreover, the driver can perform other adjustments according |
119 | to hardware limitations. The application can control rounding behaviour using | 119 | to hardware limitations. The application can control rounding behaviour using |
120 | <link linkend="v4l2-sel-flags"> constraint flags </link>.</para> | 120 | <link linkend="v4l2-selection-flags"> constraint flags </link>.</para> |
121 | 121 | ||
122 | <para>For capture devices the default composing rectangle is queried using | 122 | <para>For capture devices the default composing rectangle is queried using |
123 | <constant> V4L2_SEL_TGT_COMPOSE_DEFAULT </constant>. It is usually equal to the | 123 | <constant> V4L2_SEL_TGT_COMPOSE_DEFAULT </constant>. It is usually equal to the |
@@ -125,7 +125,7 @@ bounding rectangle.</para> | |||
125 | 125 | ||
126 | <para>The part of a buffer that is modified by the hardware is given by | 126 | <para>The part of a buffer that is modified by the hardware is given by |
127 | <constant> V4L2_SEL_TGT_COMPOSE_PADDED </constant>. It contains all pixels | 127 | <constant> V4L2_SEL_TGT_COMPOSE_PADDED </constant>. It contains all pixels |
128 | defined using <constant> V4L2_SEL_TGT_COMPOSE_ACTIVE </constant> plus all | 128 | defined using <constant> V4L2_SEL_TGT_COMPOSE </constant> plus all |
129 | padding data modified by hardware during insertion process. All pixels outside | 129 | padding data modified by hardware during insertion process. All pixels outside |
130 | this rectangle <emphasis>must not</emphasis> be changed by the hardware. The | 130 | this rectangle <emphasis>must not</emphasis> be changed by the hardware. The |
131 | content of pixels that lie inside the padded area but outside active area is | 131 | content of pixels that lie inside the padded area but outside active area is |
@@ -153,7 +153,7 @@ specified using <constant> VIDIOC_S_FMT </constant> ioctl.</para> | |||
153 | 153 | ||
154 | <para>The top left corner, width and height of the source rectangle, that is | 154 | <para>The top left corner, width and height of the source rectangle, that is |
155 | the area from which image date are processed by the hardware, is given by the | 155 | the area from which image date are processed by the hardware, is given by the |
156 | <constant> V4L2_SEL_TGT_CROP_ACTIVE </constant>. Its coordinates are expressed | 156 | <constant> V4L2_SEL_TGT_CROP </constant>. Its coordinates are expressed |
157 | in in the same coordinate system as the bounds rectangle. The active cropping | 157 | in in the same coordinate system as the bounds rectangle. The active cropping |
158 | area must lie completely inside the crop boundaries and the driver may further | 158 | area must lie completely inside the crop boundaries and the driver may further |
159 | adjust the requested size and/or position according to hardware | 159 | adjust the requested size and/or position according to hardware |
@@ -165,7 +165,7 @@ bounding rectangle.</para> | |||
165 | 165 | ||
166 | <para>The part of a video signal or graphics display where the image is | 166 | <para>The part of a video signal or graphics display where the image is |
167 | inserted by the hardware is controlled by <constant> | 167 | inserted by the hardware is controlled by <constant> |
168 | V4L2_SEL_TGT_COMPOSE_ACTIVE </constant> target. The rectangle's coordinates | 168 | V4L2_SEL_TGT_COMPOSE </constant> target. The rectangle's coordinates |
169 | are expressed in pixels. The composing rectangle must lie completely inside the | 169 | are expressed in pixels. The composing rectangle must lie completely inside the |
170 | bounds rectangle. The driver must adjust the area to fit to the bounding | 170 | bounds rectangle. The driver must adjust the area to fit to the bounding |
171 | limits. Moreover, the driver can perform other adjustments according to | 171 | limits. Moreover, the driver can perform other adjustments according to |
@@ -184,7 +184,7 @@ such a padded area is driver-dependent feature not covered by this document. | |||
184 | Driver developers are encouraged to keep padded rectangle equal to active one. | 184 | Driver developers are encouraged to keep padded rectangle equal to active one. |
185 | The padded target is accessed by the <constant> V4L2_SEL_TGT_COMPOSE_PADDED | 185 | The padded target is accessed by the <constant> V4L2_SEL_TGT_COMPOSE_PADDED |
186 | </constant> identifier. It must contain all pixels from the <constant> | 186 | </constant> identifier. It must contain all pixels from the <constant> |
187 | V4L2_SEL_TGT_COMPOSE_ACTIVE </constant> target.</para> | 187 | V4L2_SEL_TGT_COMPOSE </constant> target.</para> |
188 | 188 | ||
189 | </section> | 189 | </section> |
190 | 190 | ||
@@ -193,8 +193,8 @@ V4L2_SEL_TGT_COMPOSE_ACTIVE </constant> target.</para> | |||
193 | <title>Scaling control</title> | 193 | <title>Scaling control</title> |
194 | 194 | ||
195 | <para>An application can detect if scaling is performed by comparing the width | 195 | <para>An application can detect if scaling is performed by comparing the width |
196 | and the height of rectangles obtained using <constant> V4L2_SEL_TGT_CROP_ACTIVE | 196 | and the height of rectangles obtained using <constant> V4L2_SEL_TGT_CROP |
197 | </constant> and <constant> V4L2_SEL_TGT_COMPOSE_ACTIVE </constant> targets. If | 197 | </constant> and <constant> V4L2_SEL_TGT_COMPOSE </constant> targets. If |
198 | these are not equal then the scaling is applied. The application can compute | 198 | these are not equal then the scaling is applied. The application can compute |
199 | the scaling ratios using these values.</para> | 199 | the scaling ratios using these values.</para> |
200 | 200 | ||
@@ -252,7 +252,7 @@ area)</para> | |||
252 | ret = ioctl(fd, &VIDIOC-G-SELECTION;, &sel); | 252 | ret = ioctl(fd, &VIDIOC-G-SELECTION;, &sel); |
253 | if (ret) | 253 | if (ret) |
254 | exit(-1); | 254 | exit(-1); |
255 | sel.target = V4L2_SEL_TGT_CROP_ACTIVE; | 255 | sel.target = V4L2_SEL_TGT_CROP; |
256 | ret = ioctl(fd, &VIDIOC-S-SELECTION;, &sel); | 256 | ret = ioctl(fd, &VIDIOC-S-SELECTION;, &sel); |
257 | if (ret) | 257 | if (ret) |
258 | exit(-1); | 258 | exit(-1); |
@@ -281,7 +281,7 @@ area)</para> | |||
281 | r.left = sel.r.width / 4; | 281 | r.left = sel.r.width / 4; |
282 | r.top = sel.r.height / 4; | 282 | r.top = sel.r.height / 4; |
283 | sel.r = r; | 283 | sel.r = r; |
284 | sel.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | 284 | sel.target = V4L2_SEL_TGT_COMPOSE; |
285 | sel.flags = V4L2_SEL_FLAG_LE; | 285 | sel.flags = V4L2_SEL_FLAG_LE; |
286 | ret = ioctl(fd, &VIDIOC-S-SELECTION;, &sel); | 286 | ret = ioctl(fd, &VIDIOC-S-SELECTION;, &sel); |
287 | if (ret) | 287 | if (ret) |
@@ -298,11 +298,11 @@ V4L2_BUF_TYPE_VIDEO_OUTPUT </constant> for other devices</para> | |||
298 | 298 | ||
299 | &v4l2-selection; compose = { | 299 | &v4l2-selection; compose = { |
300 | .type = V4L2_BUF_TYPE_VIDEO_OUTPUT, | 300 | .type = V4L2_BUF_TYPE_VIDEO_OUTPUT, |
301 | .target = V4L2_SEL_TGT_COMPOSE_ACTIVE, | 301 | .target = V4L2_SEL_TGT_COMPOSE, |
302 | }; | 302 | }; |
303 | &v4l2-selection; crop = { | 303 | &v4l2-selection; crop = { |
304 | .type = V4L2_BUF_TYPE_VIDEO_OUTPUT, | 304 | .type = V4L2_BUF_TYPE_VIDEO_OUTPUT, |
305 | .target = V4L2_SEL_TGT_CROP_ACTIVE, | 305 | .target = V4L2_SEL_TGT_CROP, |
306 | }; | 306 | }; |
307 | double hscale, vscale; | 307 | double hscale, vscale; |
308 | 308 | ||
diff --git a/Documentation/DocBook/media/v4l/selections-common.xml b/Documentation/DocBook/media/v4l/selections-common.xml new file mode 100644 index 000000000000..7502f784b8cc --- /dev/null +++ b/Documentation/DocBook/media/v4l/selections-common.xml | |||
@@ -0,0 +1,164 @@ | |||
1 | <section id="v4l2-selections-common"> | ||
2 | |||
3 | <title>Common selection definitions</title> | ||
4 | |||
5 | <para>While the <link linkend="selection-api">V4L2 selection | ||
6 | API</link> and <link linkend="v4l2-subdev-selections">V4L2 subdev | ||
7 | selection APIs</link> are very similar, there's one fundamental | ||
8 | difference between the two. On sub-device API, the selection | ||
9 | rectangle refers to the media bus format, and is bound to a | ||
10 | sub-device's pad. On the V4L2 interface the selection rectangles | ||
11 | refer to the in-memory pixel format.</para> | ||
12 | |||
13 | <para>This section defines the common definitions of the | ||
14 | selection interfaces on the two APIs.</para> | ||
15 | |||
16 | <section id="v4l2-selection-targets"> | ||
17 | |||
18 | <title>Selection targets</title> | ||
19 | |||
20 | <para>The precise meaning of the selection targets may be | ||
21 | dependent on which of the two interfaces they are used.</para> | ||
22 | |||
23 | <table pgwide="1" frame="none" id="v4l2-selection-targets-table"> | ||
24 | <title>Selection target definitions</title> | ||
25 | <tgroup cols="5"> | ||
26 | <colspec colname="c1" /> | ||
27 | <colspec colname="c2" /> | ||
28 | <colspec colname="c3" /> | ||
29 | <colspec colname="c4" /> | ||
30 | <colspec colname="c5" /> | ||
31 | &cs-def; | ||
32 | <thead> | ||
33 | <row rowsep="1"> | ||
34 | <entry align="left">Target name</entry> | ||
35 | <entry align="left">id</entry> | ||
36 | <entry align="left">Definition</entry> | ||
37 | <entry align="left">Valid for V4L2</entry> | ||
38 | <entry align="left">Valid for V4L2 subdev</entry> | ||
39 | </row> | ||
40 | </thead> | ||
41 | <tbody valign="top"> | ||
42 | <row> | ||
43 | <entry><constant>V4L2_SEL_TGT_CROP</constant></entry> | ||
44 | <entry>0x0000</entry> | ||
45 | <entry>Crop rectangle. Defines the cropped area.</entry> | ||
46 | <entry>Yes</entry> | ||
47 | <entry>Yes</entry> | ||
48 | </row> | ||
49 | <row> | ||
50 | <entry><constant>V4L2_SEL_TGT_CROP_DEFAULT</constant></entry> | ||
51 | <entry>0x0001</entry> | ||
52 | <entry>Suggested cropping rectangle that covers the "whole picture".</entry> | ||
53 | <entry>Yes</entry> | ||
54 | <entry>No</entry> | ||
55 | </row> | ||
56 | <row> | ||
57 | <entry><constant>V4L2_SEL_TGT_CROP_BOUNDS</constant></entry> | ||
58 | <entry>0x0002</entry> | ||
59 | <entry>Bounds of the crop rectangle. All valid crop | ||
60 | rectangles fit inside the crop bounds rectangle. | ||
61 | </entry> | ||
62 | <entry>Yes</entry> | ||
63 | <entry>Yes</entry> | ||
64 | </row> | ||
65 | <row> | ||
66 | <entry><constant>V4L2_SEL_TGT_COMPOSE</constant></entry> | ||
67 | <entry>0x0100</entry> | ||
68 | <entry>Compose rectangle. Used to configure scaling | ||
69 | and composition.</entry> | ||
70 | <entry>Yes</entry> | ||
71 | <entry>Yes</entry> | ||
72 | </row> | ||
73 | <row> | ||
74 | <entry><constant>V4L2_SEL_TGT_COMPOSE_DEFAULT</constant></entry> | ||
75 | <entry>0x0101</entry> | ||
76 | <entry>Suggested composition rectangle that covers the "whole picture".</entry> | ||
77 | <entry>Yes</entry> | ||
78 | <entry>No</entry> | ||
79 | </row> | ||
80 | <row> | ||
81 | <entry><constant>V4L2_SEL_TGT_COMPOSE_BOUNDS</constant></entry> | ||
82 | <entry>0x0102</entry> | ||
83 | <entry>Bounds of the compose rectangle. All valid compose | ||
84 | rectangles fit inside the compose bounds rectangle.</entry> | ||
85 | <entry>Yes</entry> | ||
86 | <entry>Yes</entry> | ||
87 | </row> | ||
88 | <row> | ||
89 | <entry><constant>V4L2_SEL_TGT_COMPOSE_PADDED</constant></entry> | ||
90 | <entry>0x0103</entry> | ||
91 | <entry>The active area and all padding pixels that are inserted or | ||
92 | modified by hardware.</entry> | ||
93 | <entry>Yes</entry> | ||
94 | <entry>No</entry> | ||
95 | </row> | ||
96 | </tbody> | ||
97 | </tgroup> | ||
98 | </table> | ||
99 | |||
100 | </section> | ||
101 | |||
102 | <section id="v4l2-selection-flags"> | ||
103 | |||
104 | <title>Selection flags</title> | ||
105 | |||
106 | <table pgwide="1" frame="none" id="v4l2-selection-flags-table"> | ||
107 | <title>Selection flag definitions</title> | ||
108 | <tgroup cols="5"> | ||
109 | <colspec colname="c1" /> | ||
110 | <colspec colname="c2" /> | ||
111 | <colspec colname="c3" /> | ||
112 | <colspec colname="c4" /> | ||
113 | <colspec colname="c5" /> | ||
114 | &cs-def; | ||
115 | <thead> | ||
116 | <row rowsep="1"> | ||
117 | <entry align="left">Flag name</entry> | ||
118 | <entry align="left">id</entry> | ||
119 | <entry align="left">Definition</entry> | ||
120 | <entry align="left">Valid for V4L2</entry> | ||
121 | <entry align="left">Valid for V4L2 subdev</entry> | ||
122 | </row> | ||
123 | </thead> | ||
124 | <tbody valign="top"> | ||
125 | <row> | ||
126 | <entry><constant>V4L2_SEL_FLAG_GE</constant></entry> | ||
127 | <entry>(1 << 0)</entry> | ||
128 | <entry>Suggest the driver it should choose greater or | ||
129 | equal rectangle (in size) than was requested. Albeit the | ||
130 | driver may choose a lesser size, it will only do so due to | ||
131 | hardware limitations. Without this flag (and | ||
132 | <constant>V4L2_SEL_FLAG_LE</constant>) the | ||
133 | behaviour is to choose the closest possible | ||
134 | rectangle.</entry> | ||
135 | <entry>Yes</entry> | ||
136 | <entry>Yes</entry> | ||
137 | </row> | ||
138 | <row> | ||
139 | <entry><constant>V4L2_SEL_FLAG_LE</constant></entry> | ||
140 | <entry>(1 << 1)</entry> | ||
141 | <entry>Suggest the driver it | ||
142 | should choose lesser or equal rectangle (in size) than was | ||
143 | requested. Albeit the driver may choose a greater size, it | ||
144 | will only do so due to hardware limitations.</entry> | ||
145 | <entry>Yes</entry> | ||
146 | <entry>Yes</entry> | ||
147 | </row> | ||
148 | <row> | ||
149 | <entry><constant>V4L2_SEL_FLAG_KEEP_CONFIG</constant></entry> | ||
150 | <entry>(1 << 2)</entry> | ||
151 | <entry>The configuration must not be propagated to any | ||
152 | further processing steps. If this flag is not given, the | ||
153 | configuration is propagated inside the subdevice to all | ||
154 | further processing steps.</entry> | ||
155 | <entry>No</entry> | ||
156 | <entry>Yes</entry> | ||
157 | </row> | ||
158 | </tbody> | ||
159 | </tgroup> | ||
160 | </table> | ||
161 | |||
162 | </section> | ||
163 | |||
164 | </section> | ||
diff --git a/Documentation/DocBook/media/v4l/v4l2.xml b/Documentation/DocBook/media/v4l/v4l2.xml index 008c2d73a484..36bafc48e03b 100644 --- a/Documentation/DocBook/media/v4l/v4l2.xml +++ b/Documentation/DocBook/media/v4l/v4l2.xml | |||
@@ -589,6 +589,11 @@ and discussions on the V4L mailing list.</revremark> | |||
589 | &sub-write; | 589 | &sub-write; |
590 | </appendix> | 590 | </appendix> |
591 | 591 | ||
592 | <appendix> | ||
593 | <title>Common definitions for V4L2 and V4L2 subdev interfaces</title> | ||
594 | &sub-selections-common; | ||
595 | </appendix> | ||
596 | |||
592 | <appendix id="videodev"> | 597 | <appendix id="videodev"> |
593 | <title>Video For Linux Two Header File</title> | 598 | <title>Video For Linux Two Header File</title> |
594 | &sub-videodev2-h; | 599 | &sub-videodev2-h; |
diff --git a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml index a2474ecb574a..5e73b1c8d095 100644 --- a/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml +++ b/Documentation/DocBook/media/v4l/vidioc-create-bufs.xml | |||
@@ -97,7 +97,13 @@ information.</para> | |||
97 | <row> | 97 | <row> |
98 | <entry>__u32</entry> | 98 | <entry>__u32</entry> |
99 | <entry><structfield>count</structfield></entry> | 99 | <entry><structfield>count</structfield></entry> |
100 | <entry>The number of buffers requested or granted.</entry> | 100 | <entry>The number of buffers requested or granted. If count == 0, then |
101 | <constant>VIDIOC_CREATE_BUFS</constant> will set <structfield>index</structfield> | ||
102 | to the current number of created buffers, and it will check the validity of | ||
103 | <structfield>memory</structfield> and <structfield>format.type</structfield>. | ||
104 | If those are invalid -1 is returned and errno is set to &EINVAL;, | ||
105 | otherwise <constant>VIDIOC_CREATE_BUFS</constant> returns 0. It will | ||
106 | never set errno to &EBUSY; in this particular case.</entry> | ||
101 | </row> | 107 | </row> |
102 | <row> | 108 | <row> |
103 | <entry>__u32</entry> | 109 | <entry>__u32</entry> |
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml b/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml index 69c178a4d205..40e58a42eb26 100644 --- a/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml +++ b/Documentation/DocBook/media/v4l/vidioc-g-frequency.xml | |||
@@ -135,6 +135,12 @@ bounds or the value in the <structfield>type</structfield> field is | |||
135 | wrong.</para> | 135 | wrong.</para> |
136 | </listitem> | 136 | </listitem> |
137 | </varlistentry> | 137 | </varlistentry> |
138 | <varlistentry> | ||
139 | <term><errorcode>EBUSY</errorcode></term> | ||
140 | <listitem> | ||
141 | <para>A hardware seek is in progress.</para> | ||
142 | </listitem> | ||
143 | </varlistentry> | ||
138 | </variablelist> | 144 | </variablelist> |
139 | </refsect1> | 145 | </refsect1> |
140 | </refentry> | 146 | </refentry> |
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-selection.xml b/Documentation/DocBook/media/v4l/vidioc-g-selection.xml index bb04eff75f45..f76d8a6d9b92 100644 --- a/Documentation/DocBook/media/v4l/vidioc-g-selection.xml +++ b/Documentation/DocBook/media/v4l/vidioc-g-selection.xml | |||
@@ -65,9 +65,9 @@ Do not use multiplanar buffers. Use <constant> V4L2_BUF_TYPE_VIDEO_CAPTURE | |||
65 | </constant>. Use <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT </constant> instead of | 65 | </constant>. Use <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT </constant> instead of |
66 | <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE </constant>. The next step is | 66 | <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE </constant>. The next step is |
67 | setting the value of &v4l2-selection; <structfield>target</structfield> field | 67 | setting the value of &v4l2-selection; <structfield>target</structfield> field |
68 | to <constant> V4L2_SEL_TGT_CROP_ACTIVE </constant> (<constant> | 68 | to <constant> V4L2_SEL_TGT_CROP </constant> (<constant> |
69 | V4L2_SEL_TGT_COMPOSE_ACTIVE </constant>). Please refer to table <xref | 69 | V4L2_SEL_TGT_COMPOSE </constant>). Please refer to table <xref |
70 | linkend="v4l2-sel-target" /> or <xref linkend="selection-api" /> for additional | 70 | linkend="v4l2-selections-common" /> or <xref linkend="selection-api" /> for additional |
71 | targets. The <structfield>flags</structfield> and <structfield>reserved | 71 | targets. The <structfield>flags</structfield> and <structfield>reserved |
72 | </structfield> fields of &v4l2-selection; are ignored and they must be filled | 72 | </structfield> fields of &v4l2-selection; are ignored and they must be filled |
73 | with zeros. The driver fills the rest of the structure or | 73 | with zeros. The driver fills the rest of the structure or |
@@ -86,9 +86,9 @@ use multiplanar buffers. Use <constant> V4L2_BUF_TYPE_VIDEO_CAPTURE | |||
86 | </constant>. Use <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT </constant> instead of | 86 | </constant>. Use <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT </constant> instead of |
87 | <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE </constant>. The next step is | 87 | <constant> V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE </constant>. The next step is |
88 | setting the value of &v4l2-selection; <structfield>target</structfield> to | 88 | setting the value of &v4l2-selection; <structfield>target</structfield> to |
89 | <constant>V4L2_SEL_TGT_CROP_ACTIVE</constant> (<constant> | 89 | <constant>V4L2_SEL_TGT_CROP</constant> (<constant> |
90 | V4L2_SEL_TGT_COMPOSE_ACTIVE </constant>). Please refer to table <xref | 90 | V4L2_SEL_TGT_COMPOSE </constant>). Please refer to table <xref |
91 | linkend="v4l2-sel-target" /> or <xref linkend="selection-api" /> for additional | 91 | linkend="v4l2-selections-common" /> or <xref linkend="selection-api" /> for additional |
92 | targets. The &v4l2-rect; <structfield>r</structfield> rectangle need to be | 92 | targets. The &v4l2-rect; <structfield>r</structfield> rectangle need to be |
93 | set to the desired active area. Field &v4l2-selection; <structfield> reserved | 93 | set to the desired active area. Field &v4l2-selection; <structfield> reserved |
94 | </structfield> is ignored and must be filled with zeros. The driver may adjust | 94 | </structfield> is ignored and must be filled with zeros. The driver may adjust |
@@ -154,74 +154,8 @@ exist no rectangle </emphasis> that satisfies the constraints.</para> | |||
154 | 154 | ||
155 | </refsect1> | 155 | </refsect1> |
156 | 156 | ||
157 | <refsect1> | 157 | <para>Selection targets and flags are documented in <xref |
158 | <table frame="none" pgwide="1" id="v4l2-sel-target"> | 158 | linkend="v4l2-selections-common"/>.</para> |
159 | <title>Selection targets.</title> | ||
160 | <tgroup cols="3"> | ||
161 | &cs-def; | ||
162 | <tbody valign="top"> | ||
163 | <row> | ||
164 | <entry><constant>V4L2_SEL_TGT_CROP_ACTIVE</constant></entry> | ||
165 | <entry>0x0000</entry> | ||
166 | <entry>The area that is currently cropped by hardware.</entry> | ||
167 | </row> | ||
168 | <row> | ||
169 | <entry><constant>V4L2_SEL_TGT_CROP_DEFAULT</constant></entry> | ||
170 | <entry>0x0001</entry> | ||
171 | <entry>Suggested cropping rectangle that covers the "whole picture".</entry> | ||
172 | </row> | ||
173 | <row> | ||
174 | <entry><constant>V4L2_SEL_TGT_CROP_BOUNDS</constant></entry> | ||
175 | <entry>0x0002</entry> | ||
176 | <entry>Limits for the cropping rectangle.</entry> | ||
177 | </row> | ||
178 | <row> | ||
179 | <entry><constant>V4L2_SEL_TGT_COMPOSE_ACTIVE</constant></entry> | ||
180 | <entry>0x0100</entry> | ||
181 | <entry>The area to which data is composed by hardware.</entry> | ||
182 | </row> | ||
183 | <row> | ||
184 | <entry><constant>V4L2_SEL_TGT_COMPOSE_DEFAULT</constant></entry> | ||
185 | <entry>0x0101</entry> | ||
186 | <entry>Suggested composing rectangle that covers the "whole picture".</entry> | ||
187 | </row> | ||
188 | <row> | ||
189 | <entry><constant>V4L2_SEL_TGT_COMPOSE_BOUNDS</constant></entry> | ||
190 | <entry>0x0102</entry> | ||
191 | <entry>Limits for the composing rectangle.</entry> | ||
192 | </row> | ||
193 | <row> | ||
194 | <entry><constant>V4L2_SEL_TGT_COMPOSE_PADDED</constant></entry> | ||
195 | <entry>0x0103</entry> | ||
196 | <entry>The active area and all padding pixels that are inserted or modified by hardware.</entry> | ||
197 | </row> | ||
198 | </tbody> | ||
199 | </tgroup> | ||
200 | </table> | ||
201 | </refsect1> | ||
202 | |||
203 | <refsect1> | ||
204 | <table frame="none" pgwide="1" id="v4l2-sel-flags"> | ||
205 | <title>Selection constraint flags</title> | ||
206 | <tgroup cols="3"> | ||
207 | &cs-def; | ||
208 | <tbody valign="top"> | ||
209 | <row> | ||
210 | <entry><constant>V4L2_SEL_FLAG_GE</constant></entry> | ||
211 | <entry>0x00000001</entry> | ||
212 | <entry>Indicates that the adjusted rectangle must contain the original | ||
213 | &v4l2-selection; <structfield>r</structfield> rectangle.</entry> | ||
214 | </row> | ||
215 | <row> | ||
216 | <entry><constant>V4L2_SEL_FLAG_LE</constant></entry> | ||
217 | <entry>0x00000002</entry> | ||
218 | <entry>Indicates that the adjusted rectangle must be inside the original | ||
219 | &v4l2-rect; <structfield>r</structfield> rectangle.</entry> | ||
220 | </row> | ||
221 | </tbody> | ||
222 | </tgroup> | ||
223 | </table> | ||
224 | </refsect1> | ||
225 | 159 | ||
226 | <section> | 160 | <section> |
227 | <figure id="sel-const-adjust"> | 161 | <figure id="sel-const-adjust"> |
@@ -252,14 +186,14 @@ exist no rectangle </emphasis> that satisfies the constraints.</para> | |||
252 | <row> | 186 | <row> |
253 | <entry>__u32</entry> | 187 | <entry>__u32</entry> |
254 | <entry><structfield>target</structfield></entry> | 188 | <entry><structfield>target</structfield></entry> |
255 | <entry>Used to select between <link linkend="v4l2-sel-target"> cropping | 189 | <entry>Used to select between <link linkend="v4l2-selections-common"> cropping |
256 | and composing rectangles</link>.</entry> | 190 | and composing rectangles</link>.</entry> |
257 | </row> | 191 | </row> |
258 | <row> | 192 | <row> |
259 | <entry>__u32</entry> | 193 | <entry>__u32</entry> |
260 | <entry><structfield>flags</structfield></entry> | 194 | <entry><structfield>flags</structfield></entry> |
261 | <entry>Flags controlling the selection rectangle adjustments, refer to | 195 | <entry>Flags controlling the selection rectangle adjustments, refer to |
262 | <link linkend="v4l2-sel-flags">selection flags</link>.</entry> | 196 | <link linkend="v4l2-selection-flags">selection flags</link>.</entry> |
263 | </row> | 197 | </row> |
264 | <row> | 198 | <row> |
265 | <entry>&v4l2-rect;</entry> | 199 | <entry>&v4l2-rect;</entry> |
diff --git a/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml b/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml index 62a1aa200a36..95d5371c1709 100644 --- a/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml +++ b/Documentation/DocBook/media/v4l/vidioc-g-tuner.xml | |||
@@ -276,6 +276,18 @@ can or must be switched. (B/G PAL tuners for example are typically not | |||
276 | <constant>V4L2_TUNER_ANALOG_TV</constant> tuners can have this capability.</entry> | 276 | <constant>V4L2_TUNER_ANALOG_TV</constant> tuners can have this capability.</entry> |
277 | </row> | 277 | </row> |
278 | <row> | 278 | <row> |
279 | <entry><constant>V4L2_TUNER_CAP_HWSEEK_BOUNDED</constant></entry> | ||
280 | <entry>0x0004</entry> | ||
281 | <entry>If set, then this tuner supports the hardware seek functionality | ||
282 | where the seek stops when it reaches the end of the frequency range.</entry> | ||
283 | </row> | ||
284 | <row> | ||
285 | <entry><constant>V4L2_TUNER_CAP_HWSEEK_WRAP</constant></entry> | ||
286 | <entry>0x0008</entry> | ||
287 | <entry>If set, then this tuner supports the hardware seek functionality | ||
288 | where the seek wraps around when it reaches the end of the frequency range.</entry> | ||
289 | </row> | ||
290 | <row> | ||
279 | <entry><constant>V4L2_TUNER_CAP_STEREO</constant></entry> | 291 | <entry><constant>V4L2_TUNER_CAP_STEREO</constant></entry> |
280 | <entry>0x0010</entry> | 292 | <entry>0x0010</entry> |
281 | <entry>Stereo audio reception is supported.</entry> | 293 | <entry>Stereo audio reception is supported.</entry> |
diff --git a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml index 9caa49af580f..77ff5be0809d 100644 --- a/Documentation/DocBook/media/v4l/vidioc-qbuf.xml +++ b/Documentation/DocBook/media/v4l/vidioc-qbuf.xml | |||
@@ -71,12 +71,9 @@ initialize the <structfield>bytesused</structfield>, | |||
71 | <structfield>field</structfield> and | 71 | <structfield>field</structfield> and |
72 | <structfield>timestamp</structfield> fields, see <xref | 72 | <structfield>timestamp</structfield> fields, see <xref |
73 | linkend="buffer" /> for details. | 73 | linkend="buffer" /> for details. |
74 | Applications must also set <structfield>flags</structfield> to 0. If a driver | 74 | Applications must also set <structfield>flags</structfield> to 0. |
75 | supports capturing from specific video inputs and you want to specify a video | 75 | The <structfield>reserved2</structfield> and |
76 | input, then <structfield>flags</structfield> should be set to | 76 | <structfield>reserved</structfield> fields must be set to 0. When using |
77 | <constant>V4L2_BUF_FLAG_INPUT</constant> and the field | ||
78 | <structfield>input</structfield> must be initialized to the desired input. | ||
79 | The <structfield>reserved</structfield> field must be set to 0. When using | ||
80 | the <link linkend="planar-apis">multi-planar API</link>, the | 77 | the <link linkend="planar-apis">multi-planar API</link>, the |
81 | <structfield>m.planes</structfield> field must contain a userspace pointer | 78 | <structfield>m.planes</structfield> field must contain a userspace pointer |
82 | to a filled-in array of &v4l2-plane; and the <structfield>length</structfield> | 79 | to a filled-in array of &v4l2-plane; and the <structfield>length</structfield> |
diff --git a/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml b/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml index 407dfceb71f0..f4db44d0d95a 100644 --- a/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml +++ b/Documentation/DocBook/media/v4l/vidioc-s-hw-freq-seek.xml | |||
@@ -58,6 +58,9 @@ To do this applications initialize the <structfield>tuner</structfield>, | |||
58 | call the <constant>VIDIOC_S_HW_FREQ_SEEK</constant> ioctl with a pointer | 58 | call the <constant>VIDIOC_S_HW_FREQ_SEEK</constant> ioctl with a pointer |
59 | to this structure.</para> | 59 | to this structure.</para> |
60 | 60 | ||
61 | <para>If an error is returned, then the original frequency will | ||
62 | be restored.</para> | ||
63 | |||
61 | <para>This ioctl is supported if the <constant>V4L2_CAP_HW_FREQ_SEEK</constant> capability is set.</para> | 64 | <para>This ioctl is supported if the <constant>V4L2_CAP_HW_FREQ_SEEK</constant> capability is set.</para> |
62 | 65 | ||
63 | <table pgwide="1" frame="none" id="v4l2-hw-freq-seek"> | 66 | <table pgwide="1" frame="none" id="v4l2-hw-freq-seek"> |
@@ -87,7 +90,10 @@ field and the &v4l2-tuner; <structfield>index</structfield> field.</entry> | |||
87 | <row> | 90 | <row> |
88 | <entry>__u32</entry> | 91 | <entry>__u32</entry> |
89 | <entry><structfield>wrap_around</structfield></entry> | 92 | <entry><structfield>wrap_around</structfield></entry> |
90 | <entry>If non-zero, wrap around when at the end of the frequency range, else stop seeking.</entry> | 93 | <entry>If non-zero, wrap around when at the end of the frequency range, else stop seeking. |
94 | The &v4l2-tuner; <structfield>capability</structfield> field will tell you what the | ||
95 | hardware supports. | ||
96 | </entry> | ||
91 | </row> | 97 | </row> |
92 | <row> | 98 | <row> |
93 | <entry>__u32</entry> | 99 | <entry>__u32</entry> |
@@ -118,9 +124,15 @@ wrong.</para> | |||
118 | </listitem> | 124 | </listitem> |
119 | </varlistentry> | 125 | </varlistentry> |
120 | <varlistentry> | 126 | <varlistentry> |
121 | <term><errorcode>EAGAIN</errorcode></term> | 127 | <term><errorcode>ENODATA</errorcode></term> |
128 | <listitem> | ||
129 | <para>The hardware seek found no channels.</para> | ||
130 | </listitem> | ||
131 | </varlistentry> | ||
132 | <varlistentry> | ||
133 | <term><errorcode>EBUSY</errorcode></term> | ||
122 | <listitem> | 134 | <listitem> |
123 | <para>The ioctl timed-out. Try again.</para> | 135 | <para>Another hardware seek is already in progress.</para> |
124 | </listitem> | 136 | </listitem> |
125 | </varlistentry> | 137 | </varlistentry> |
126 | </variablelist> | 138 | </variablelist> |
diff --git a/Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml b/Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml index 208e9f0da3f3..f33cc814a01d 100644 --- a/Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml +++ b/Documentation/DocBook/media/v4l/vidioc-subdev-g-selection.xml | |||
@@ -72,10 +72,10 @@ | |||
72 | <section> | 72 | <section> |
73 | <title>Types of selection targets</title> | 73 | <title>Types of selection targets</title> |
74 | 74 | ||
75 | <para>There are two types of selection targets: actual and bounds. | 75 | <para>There are two types of selection targets: actual and bounds. The |
76 | The ACTUAL targets are the targets which configure the hardware. | 76 | actual targets are the targets which configure the hardware. The BOUNDS |
77 | The BOUNDS target will return a rectangle that contain all | 77 | target will return a rectangle that contain all possible actual |
78 | possible ACTUAL rectangles.</para> | 78 | rectangles.</para> |
79 | </section> | 79 | </section> |
80 | 80 | ||
81 | <section> | 81 | <section> |
@@ -87,71 +87,8 @@ | |||
87 | <constant>EINVAL</constant>.</para> | 87 | <constant>EINVAL</constant>.</para> |
88 | </section> | 88 | </section> |
89 | 89 | ||
90 | <table pgwide="1" frame="none" id="v4l2-subdev-selection-targets"> | 90 | <para>Selection targets and flags are documented in <xref |
91 | <title>V4L2 subdev selection targets</title> | 91 | linkend="v4l2-selections-common"/>.</para> |
92 | <tgroup cols="3"> | ||
93 | &cs-def; | ||
94 | <tbody valign="top"> | ||
95 | <row> | ||
96 | <entry><constant>V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL</constant></entry> | ||
97 | <entry>0x0000</entry> | ||
98 | <entry>Actual crop. Defines the cropping | ||
99 | performed by the processing step.</entry> | ||
100 | </row> | ||
101 | <row> | ||
102 | <entry><constant>V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS</constant></entry> | ||
103 | <entry>0x0002</entry> | ||
104 | <entry>Bounds of the crop rectangle.</entry> | ||
105 | </row> | ||
106 | <row> | ||
107 | <entry><constant>V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL</constant></entry> | ||
108 | <entry>0x0100</entry> | ||
109 | <entry>Actual compose rectangle. Used to configure scaling | ||
110 | on sink pads and composition on source pads.</entry> | ||
111 | </row> | ||
112 | <row> | ||
113 | <entry><constant>V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS</constant></entry> | ||
114 | <entry>0x0102</entry> | ||
115 | <entry>Bounds of the compose rectangle.</entry> | ||
116 | </row> | ||
117 | </tbody> | ||
118 | </tgroup> | ||
119 | </table> | ||
120 | |||
121 | <table pgwide="1" frame="none" id="v4l2-subdev-selection-flags"> | ||
122 | <title>V4L2 subdev selection flags</title> | ||
123 | <tgroup cols="3"> | ||
124 | &cs-def; | ||
125 | <tbody valign="top"> | ||
126 | <row> | ||
127 | <entry><constant>V4L2_SUBDEV_SEL_FLAG_SIZE_GE</constant></entry> | ||
128 | <entry>(1 << 0)</entry> <entry>Suggest the driver it | ||
129 | should choose greater or equal rectangle (in size) than | ||
130 | was requested. Albeit the driver may choose a lesser size, | ||
131 | it will only do so due to hardware limitations. Without | ||
132 | this flag (and | ||
133 | <constant>V4L2_SUBDEV_SEL_FLAG_SIZE_LE</constant>) the | ||
134 | behaviour is to choose the closest possible | ||
135 | rectangle.</entry> | ||
136 | </row> | ||
137 | <row> | ||
138 | <entry><constant>V4L2_SUBDEV_SEL_FLAG_SIZE_LE</constant></entry> | ||
139 | <entry>(1 << 1)</entry> <entry>Suggest the driver it | ||
140 | should choose lesser or equal rectangle (in size) than was | ||
141 | requested. Albeit the driver may choose a greater size, it | ||
142 | will only do so due to hardware limitations.</entry> | ||
143 | </row> | ||
144 | <row> | ||
145 | <entry><constant>V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG</constant></entry> | ||
146 | <entry>(1 << 2)</entry> | ||
147 | <entry>The configuration should not be propagated to any | ||
148 | further processing steps. If this flag is not given, the | ||
149 | configuration is propagated inside the subdevice to all | ||
150 | further processing steps.</entry> | ||
151 | </row> | ||
152 | </tbody> | ||
153 | </tgroup> | ||
154 | </table> | ||
155 | 92 | ||
156 | <table pgwide="1" frame="none" id="v4l2-subdev-selection"> | 93 | <table pgwide="1" frame="none" id="v4l2-subdev-selection"> |
157 | <title>struct <structname>v4l2_subdev_selection</structname></title> | 94 | <title>struct <structname>v4l2_subdev_selection</structname></title> |
@@ -173,13 +110,13 @@ | |||
173 | <entry>__u32</entry> | 110 | <entry>__u32</entry> |
174 | <entry><structfield>target</structfield></entry> | 111 | <entry><structfield>target</structfield></entry> |
175 | <entry>Target selection rectangle. See | 112 | <entry>Target selection rectangle. See |
176 | <xref linkend="v4l2-subdev-selection-targets">.</xref>.</entry> | 113 | <xref linkend="v4l2-selections-common" />.</entry> |
177 | </row> | 114 | </row> |
178 | <row> | 115 | <row> |
179 | <entry>__u32</entry> | 116 | <entry>__u32</entry> |
180 | <entry><structfield>flags</structfield></entry> | 117 | <entry><structfield>flags</structfield></entry> |
181 | <entry>Flags. See | 118 | <entry>Flags. See |
182 | <xref linkend="v4l2-subdev-selection-flags">.</xref></entry> | 119 | <xref linkend="v4l2-selection-flags" />.</entry> |
183 | </row> | 120 | </row> |
184 | <row> | 121 | <row> |
185 | <entry>&v4l2-rect;</entry> | 122 | <entry>&v4l2-rect;</entry> |
diff --git a/Documentation/dvb/get_dvb_firmware b/Documentation/dvb/get_dvb_firmware index fbb241174486..12d3952e83d5 100755 --- a/Documentation/dvb/get_dvb_firmware +++ b/Documentation/dvb/get_dvb_firmware | |||
@@ -29,7 +29,7 @@ use IO::Handle; | |||
29 | "af9015", "ngene", "az6027", "lme2510_lg", "lme2510c_s7395", | 29 | "af9015", "ngene", "az6027", "lme2510_lg", "lme2510c_s7395", |
30 | "lme2510c_s7395_old", "drxk", "drxk_terratec_h5", | 30 | "lme2510c_s7395_old", "drxk", "drxk_terratec_h5", |
31 | "drxk_hauppauge_hvr930c", "tda10071", "it9135", "it9137", | 31 | "drxk_hauppauge_hvr930c", "tda10071", "it9135", "it9137", |
32 | "drxk_pctv"); | 32 | "drxk_pctv", "drxk_terratec_htc_stick", "sms1xxx_hcw"); |
33 | 33 | ||
34 | # Check args | 34 | # Check args |
35 | syntax() if (scalar(@ARGV) != 1); | 35 | syntax() if (scalar(@ARGV) != 1); |
@@ -676,6 +676,24 @@ sub drxk_terratec_h5 { | |||
676 | "$fwfile" | 676 | "$fwfile" |
677 | } | 677 | } |
678 | 678 | ||
679 | sub drxk_terratec_htc_stick { | ||
680 | my $url = "http://ftp.terratec.de/Receiver/Cinergy_HTC_Stick/Updates/"; | ||
681 | my $zipfile = "Cinergy_HTC_Stick_Drv_5.09.1202.00_XP_Vista_7.exe"; | ||
682 | my $hash = "6722a2442a05423b781721fbc069ed5e"; | ||
683 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); | ||
684 | my $drvfile = "Cinergy HTC Stick/BDA Driver 5.09.1202.00/Windows 32 Bit/emOEM.sys"; | ||
685 | my $fwfile = "dvb-usb-terratec-htc-stick-drxk.fw"; | ||
686 | |||
687 | checkstandard(); | ||
688 | |||
689 | wgetfile($zipfile, $url . $zipfile); | ||
690 | verify($zipfile, $hash); | ||
691 | unzip($zipfile, $tmpdir); | ||
692 | extract("$tmpdir/$drvfile", 0x4e5c0, 42692, "$fwfile"); | ||
693 | |||
694 | "$fwfile" | ||
695 | } | ||
696 | |||
679 | sub it9135 { | 697 | sub it9135 { |
680 | my $sourcefile = "dvb-usb-it9135.zip"; | 698 | my $sourcefile = "dvb-usb-it9135.zip"; |
681 | my $url = "http://www.ite.com.tw/uploads/firmware/v3.6.0.0/$sourcefile"; | 699 | my $url = "http://www.ite.com.tw/uploads/firmware/v3.6.0.0/$sourcefile"; |
@@ -748,6 +766,28 @@ sub drxk_pctv { | |||
748 | "$fwfile"; | 766 | "$fwfile"; |
749 | } | 767 | } |
750 | 768 | ||
769 | sub sms1xxx_hcw { | ||
770 | my $url = "http://steventoth.net/linux/sms1xxx/"; | ||
771 | my %files = ( | ||
772 | 'sms1xxx-hcw-55xxx-dvbt-01.fw' => "afb6f9fb9a71d64392e8564ef9577e5a", | ||
773 | 'sms1xxx-hcw-55xxx-dvbt-02.fw' => "b44807098ba26e52cbedeadc052ba58f", | ||
774 | 'sms1xxx-hcw-55xxx-isdbt-02.fw' => "dae934eeea85225acbd63ce6cfe1c9e4", | ||
775 | ); | ||
776 | |||
777 | checkstandard(); | ||
778 | |||
779 | my $allfiles; | ||
780 | foreach my $fwfile (keys %files) { | ||
781 | wgetfile($fwfile, "$url/$fwfile"); | ||
782 | verify($fwfile, $files{$fwfile}); | ||
783 | $allfiles .= " $fwfile"; | ||
784 | } | ||
785 | |||
786 | $allfiles =~ s/^\s//; | ||
787 | |||
788 | $allfiles; | ||
789 | } | ||
790 | |||
751 | # --------------------------------------------------------------- | 791 | # --------------------------------------------------------------- |
752 | # Utilities | 792 | # Utilities |
753 | 793 | ||
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 09701afc031a..b99803066b7b 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -558,3 +558,21 @@ Why: The V4L2_CID_VCENTER, V4L2_CID_HCENTER controls have been deprecated | |||
558 | There are newer controls (V4L2_CID_PAN*, V4L2_CID_TILT*) that provide | 558 | There are newer controls (V4L2_CID_PAN*, V4L2_CID_TILT*) that provide |
559 | similar functionality. | 559 | similar functionality. |
560 | Who: Sylwester Nawrocki <sylvester.nawrocki@gmail.com> | 560 | Who: Sylwester Nawrocki <sylvester.nawrocki@gmail.com> |
561 | |||
562 | ---------------------------- | ||
563 | |||
564 | What: V4L2 selections API target rectangle and flags unification, the | ||
565 | following definitions will be removed: V4L2_SEL_TGT_CROP_ACTIVE, | ||
566 | V4L2_SEL_TGT_COMPOSE_ACTIVE, V4L2_SUBDEV_SEL_*, V4L2_SUBDEV_SEL_FLAG_* | ||
567 | in favor of common V4L2_SEL_TGT_* and V4L2_SEL_FLAG_* definitions. | ||
568 | For more details see include/linux/v4l2-common.h. | ||
569 | When: 3.8 | ||
570 | Why: The regular V4L2 selections and the subdev selection API originally | ||
571 | defined distinct names for the target rectangles and flags - V4L2_SEL_* | ||
572 | and V4L2_SUBDEV_SEL_*. Although, it turned out that the meaning of these | ||
573 | target rectangles is virtually identical and the APIs were consolidated | ||
574 | to use single set of names - V4L2_SEL_*. This didn't involve any ABI | ||
575 | changes. Alias definitions were created for the original ones to avoid | ||
576 | any instabilities in the user space interface. After few cycles these | ||
577 | backward compatibility definitions will be removed. | ||
578 | Who: Sylwester Nawrocki <sylvester.nawrocki@gmail.com> | ||
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 1f5905270050..89318be6c1d2 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt | |||
@@ -594,6 +594,15 @@ You should also set these fields: | |||
594 | unlocked_ioctl file operation is called this lock will be taken by the | 594 | unlocked_ioctl file operation is called this lock will be taken by the |
595 | core and released afterwards. See the next section for more details. | 595 | core and released afterwards. See the next section for more details. |
596 | 596 | ||
597 | - queue: a pointer to the struct vb2_queue associated with this device node. | ||
598 | If queue is non-NULL, and queue->lock is non-NULL, then queue->lock is | ||
599 | used for the queuing ioctls (VIDIOC_REQBUFS, CREATE_BUFS, QBUF, DQBUF, | ||
600 | QUERYBUF, PREPARE_BUF, STREAMON and STREAMOFF) instead of the lock above. | ||
601 | That way the vb2 queuing framework does not have to wait for other ioctls. | ||
602 | This queue pointer is also used by the vb2 helper functions to check for | ||
603 | queuing ownership (i.e. is the filehandle calling it allowed to do the | ||
604 | operation). | ||
605 | |||
597 | - prio: keeps track of the priorities. Used to implement VIDIOC_G/S_PRIORITY. | 606 | - prio: keeps track of the priorities. Used to implement VIDIOC_G/S_PRIORITY. |
598 | If left to NULL, then it will use the struct v4l2_prio_state in v4l2_device. | 607 | If left to NULL, then it will use the struct v4l2_prio_state in v4l2_device. |
599 | If you want to have a separate priority state per (group of) device node(s), | 608 | If you want to have a separate priority state per (group of) device node(s), |
@@ -647,47 +656,43 @@ manually set the struct media_entity type and name fields. | |||
647 | A reference to the entity will be automatically acquired/released when the | 656 | A reference to the entity will be automatically acquired/released when the |
648 | video device is opened/closed. | 657 | video device is opened/closed. |
649 | 658 | ||
650 | v4l2_file_operations and locking | 659 | ioctls and locking |
651 | -------------------------------- | 660 | ------------------ |
652 | |||
653 | You can set a pointer to a mutex_lock in struct video_device. Usually this | ||
654 | will be either a top-level mutex or a mutex per device node. By default this | ||
655 | lock will be used for unlocked_ioctl, but you can disable locking for | ||
656 | selected ioctls by calling: | ||
657 | |||
658 | void v4l2_disable_ioctl_locking(struct video_device *vdev, unsigned int cmd); | ||
659 | |||
660 | E.g.: v4l2_disable_ioctl_locking(vdev, VIDIOC_DQBUF); | ||
661 | 661 | ||
662 | You have to call this before you register the video_device. | 662 | The V4L core provides optional locking services. The main service is the |
663 | lock field in struct video_device, which is a pointer to a mutex. If you set | ||
664 | this pointer, then that will be used by unlocked_ioctl to serialize all ioctls. | ||
663 | 665 | ||
664 | Particularly with USB drivers where certain commands such as setting controls | 666 | If you are using the videobuf2 framework, then there is a second lock that you |
665 | can take a long time you may want to do your own locking for the buffer queuing | 667 | can set: video_device->queue->lock. If set, then this lock will be used instead |
666 | ioctls. | 668 | of video_device->lock to serialize all queuing ioctls (see the previous section |
669 | for the full list of those ioctls). | ||
667 | 670 | ||
668 | If you want still finer-grained locking then you have to set mutex_lock to NULL | 671 | The advantage of using a different lock for the queuing ioctls is that for some |
669 | and do you own locking completely. | 672 | drivers (particularly USB drivers) certain commands such as setting controls |
673 | can take a long time, so you want to use a separate lock for the buffer queuing | ||
674 | ioctls. That way your VIDIOC_DQBUF doesn't stall because the driver is busy | ||
675 | changing the e.g. exposure of the webcam. | ||
670 | 676 | ||
671 | It is up to the driver developer to decide which method to use. However, if | 677 | Of course, you can always do all the locking yourself by leaving both lock |
672 | your driver has high-latency operations (for example, changing the exposure | 678 | pointers at NULL. |
673 | of a USB webcam might take a long time), then you might be better off with | ||
674 | doing your own locking if you want to allow the user to do other things with | ||
675 | the device while waiting for the high-latency command to finish. | ||
676 | 679 | ||
677 | If a lock is specified then all ioctl commands will be serialized on that | 680 | If you use the old videobuf then you must pass the video_device lock to the |
678 | lock. If you use videobuf then you must pass the same lock to the videobuf | 681 | videobuf queue initialize function: if videobuf has to wait for a frame to |
679 | queue initialize function: if videobuf has to wait for a frame to arrive, then | 682 | arrive, then it will temporarily unlock the lock and relock it afterwards. If |
680 | it will temporarily unlock the lock and relock it afterwards. If your driver | 683 | your driver also waits in the code, then you should do the same to allow other |
681 | also waits in the code, then you should do the same to allow other processes | 684 | processes to access the device node while the first process is waiting for |
682 | to access the device node while the first process is waiting for something. | 685 | something. |
683 | 686 | ||
684 | In the case of videobuf2 you will need to implement the wait_prepare and | 687 | In the case of videobuf2 you will need to implement the wait_prepare and |
685 | wait_finish callbacks to unlock/lock if applicable. In particular, if you use | 688 | wait_finish callbacks to unlock/lock if applicable. If you use the queue->lock |
686 | the lock in struct video_device then you must unlock/lock this mutex in | 689 | pointer, then you can use the helper functions vb2_ops_wait_prepare/finish. |
687 | wait_prepare and wait_finish. | 690 | |
688 | 691 | The implementation of a hotplug disconnect should also take the lock from | |
689 | The implementation of a hotplug disconnect should also take the lock before | 692 | video_device before calling v4l2_device_disconnect. If you are also using |
690 | calling v4l2_device_disconnect. | 693 | video_device->queue->lock, then you have to first lock video_device->queue->lock |
694 | followed by video_device->lock. That way you can be sure no ioctl is running | ||
695 | when you call v4l2_device_disconnect. | ||
691 | 696 | ||
692 | video_device registration | 697 | video_device registration |
693 | ------------------------- | 698 | ------------------------- |
diff --git a/MAINTAINERS b/MAINTAINERS index f175f444cb55..aaa63da72ab6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -3061,8 +3061,7 @@ S: Maintained | |||
3061 | F: drivers/media/video/gspca/t613.c | 3061 | F: drivers/media/video/gspca/t613.c |
3062 | 3062 | ||
3063 | GSPCA USB WEBCAM DRIVER | 3063 | GSPCA USB WEBCAM DRIVER |
3064 | M: Jean-Francois Moine <moinejf@free.fr> | 3064 | M: Hans de Goede <hdegoede@redhat.com> |
3065 | W: http://moinejf.free.fr | ||
3066 | L: linux-media@vger.kernel.org | 3065 | L: linux-media@vger.kernel.org |
3067 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git | 3066 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media.git |
3068 | S: Maintained | 3067 | S: Maintained |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index feb7dc359186..ccc6445979c4 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -1295,6 +1295,37 @@ module_exit(i2c_exit); | |||
1295 | */ | 1295 | */ |
1296 | 1296 | ||
1297 | /** | 1297 | /** |
1298 | * __i2c_transfer - unlocked flavor of i2c_transfer | ||
1299 | * @adap: Handle to I2C bus | ||
1300 | * @msgs: One or more messages to execute before STOP is issued to | ||
1301 | * terminate the operation; each message begins with a START. | ||
1302 | * @num: Number of messages to be executed. | ||
1303 | * | ||
1304 | * Returns negative errno, else the number of messages executed. | ||
1305 | * | ||
1306 | * Adapter lock must be held when calling this function. No debug logging | ||
1307 | * takes place. adap->algo->master_xfer existence isn't checked. | ||
1308 | */ | ||
1309 | int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | ||
1310 | { | ||
1311 | unsigned long orig_jiffies; | ||
1312 | int ret, try; | ||
1313 | |||
1314 | /* Retry automatically on arbitration loss */ | ||
1315 | orig_jiffies = jiffies; | ||
1316 | for (ret = 0, try = 0; try <= adap->retries; try++) { | ||
1317 | ret = adap->algo->master_xfer(adap, msgs, num); | ||
1318 | if (ret != -EAGAIN) | ||
1319 | break; | ||
1320 | if (time_after(jiffies, orig_jiffies + adap->timeout)) | ||
1321 | break; | ||
1322 | } | ||
1323 | |||
1324 | return ret; | ||
1325 | } | ||
1326 | EXPORT_SYMBOL(__i2c_transfer); | ||
1327 | |||
1328 | /** | ||
1298 | * i2c_transfer - execute a single or combined I2C message | 1329 | * i2c_transfer - execute a single or combined I2C message |
1299 | * @adap: Handle to I2C bus | 1330 | * @adap: Handle to I2C bus |
1300 | * @msgs: One or more messages to execute before STOP is issued to | 1331 | * @msgs: One or more messages to execute before STOP is issued to |
@@ -1308,8 +1339,7 @@ module_exit(i2c_exit); | |||
1308 | */ | 1339 | */ |
1309 | int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | 1340 | int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) |
1310 | { | 1341 | { |
1311 | unsigned long orig_jiffies; | 1342 | int ret; |
1312 | int ret, try; | ||
1313 | 1343 | ||
1314 | /* REVISIT the fault reporting model here is weak: | 1344 | /* REVISIT the fault reporting model here is weak: |
1315 | * | 1345 | * |
@@ -1347,15 +1377,7 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) | |||
1347 | i2c_lock_adapter(adap); | 1377 | i2c_lock_adapter(adap); |
1348 | } | 1378 | } |
1349 | 1379 | ||
1350 | /* Retry automatically on arbitration loss */ | 1380 | ret = __i2c_transfer(adap, msgs, num); |
1351 | orig_jiffies = jiffies; | ||
1352 | for (ret = 0, try = 0; try <= adap->retries; try++) { | ||
1353 | ret = adap->algo->master_xfer(adap, msgs, num); | ||
1354 | if (ret != -EAGAIN) | ||
1355 | break; | ||
1356 | if (time_after(jiffies, orig_jiffies + adap->timeout)) | ||
1357 | break; | ||
1358 | } | ||
1359 | i2c_unlock_adapter(adap); | 1381 | i2c_unlock_adapter(adap); |
1360 | 1382 | ||
1361 | return ret; | 1383 | return ret; |
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index 9575db429df4..d941581ab921 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig | |||
@@ -6,20 +6,82 @@ menuconfig MEDIA_SUPPORT | |||
6 | tristate "Multimedia support" | 6 | tristate "Multimedia support" |
7 | depends on HAS_IOMEM | 7 | depends on HAS_IOMEM |
8 | help | 8 | help |
9 | If you want to use Video for Linux, DVB for Linux, or DAB adapters, | 9 | If you want to use Webcams, Video grabber devices and/or TV devices |
10 | enable this option and other options below. | 10 | enable this option and other options below. |
11 | Additional info and docs are available on the web at | ||
12 | <http://linuxtv.org> | ||
11 | 13 | ||
12 | if MEDIA_SUPPORT | 14 | if MEDIA_SUPPORT |
13 | 15 | ||
14 | comment "Multimedia core support" | 16 | comment "Multimedia core support" |
15 | 17 | ||
16 | # | 18 | # |
19 | # Multimedia support - automatically enable V4L2 and DVB core | ||
20 | # | ||
21 | config MEDIA_CAMERA_SUPPORT | ||
22 | bool "Cameras/video grabbers support" | ||
23 | ---help--- | ||
24 | Enable support for webcams and video grabbers. | ||
25 | |||
26 | Say Y when you have a webcam or a video capture grabber board. | ||
27 | |||
28 | config MEDIA_ANALOG_TV_SUPPORT | ||
29 | bool "Analog TV support" | ||
30 | ---help--- | ||
31 | Enable analog TV support. | ||
32 | |||
33 | Say Y when you have a TV board with analog support or with a | ||
34 | hybrid analog/digital TV chipset. | ||
35 | |||
36 | Note: There are several DVB cards that are based on chips that | ||
37 | support both analog and digital TV. Disabling this option | ||
38 | will disable support for them. | ||
39 | |||
40 | config MEDIA_DIGITAL_TV_SUPPORT | ||
41 | bool "Digital TV support" | ||
42 | ---help--- | ||
43 | Enable digital TV support. | ||
44 | |||
45 | Say Y when you have a board with digital support or a board with | ||
46 | hybrid digital TV and analog TV. | ||
47 | |||
48 | config MEDIA_RADIO_SUPPORT | ||
49 | bool "AM/FM radio receivers/transmitters support" | ||
50 | ---help--- | ||
51 | Enable AM/FM radio support. | ||
52 | |||
53 | Additional info and docs are available on the web at | ||
54 | <http://linuxtv.org> | ||
55 | |||
56 | Say Y when you have a board with radio support. | ||
57 | |||
58 | Note: There are several TV cards that are based on chips that | ||
59 | support radio reception. Disabling this option will | ||
60 | disable support for them. | ||
61 | |||
62 | config MEDIA_RC_SUPPORT | ||
63 | bool "Remote Controller support" | ||
64 | depends on INPUT | ||
65 | ---help--- | ||
66 | Enable support for Remote Controllers on Linux. This is | ||
67 | needed in order to support several video capture adapters, | ||
68 | standalone IR receivers/transmitters, and RF receivers. | ||
69 | |||
70 | Enable this option if you have a video capture board even | ||
71 | if you don't need IR, as otherwise, you may not be able to | ||
72 | compile the driver for your adapter. | ||
73 | |||
74 | Say Y when you have a TV or an IR device. | ||
75 | |||
76 | # | ||
17 | # Media controller | 77 | # Media controller |
78 | # Selectable only for webcam/grabbers, as other drivers don't use it | ||
18 | # | 79 | # |
19 | 80 | ||
20 | config MEDIA_CONTROLLER | 81 | config MEDIA_CONTROLLER |
21 | bool "Media Controller API (EXPERIMENTAL)" | 82 | bool "Media Controller API (EXPERIMENTAL)" |
22 | depends on EXPERIMENTAL | 83 | depends on EXPERIMENTAL |
84 | depends on MEDIA_CAMERA_SUPPORT | ||
23 | ---help--- | 85 | ---help--- |
24 | Enable the media controller API used to query media devices internal | 86 | Enable the media controller API used to query media devices internal |
25 | topology and configure it dynamically. | 87 | topology and configure it dynamically. |
@@ -27,26 +89,15 @@ config MEDIA_CONTROLLER | |||
27 | This API is mostly used by camera interfaces in embedded platforms. | 89 | This API is mostly used by camera interfaces in embedded platforms. |
28 | 90 | ||
29 | # | 91 | # |
30 | # V4L core and enabled API's | 92 | # Video4Linux support |
93 | # Only enables if one of the V4L2 types (ATV, webcam, radio) is selected | ||
31 | # | 94 | # |
32 | 95 | ||
33 | config VIDEO_DEV | 96 | config VIDEO_DEV |
34 | tristate "Video For Linux" | 97 | tristate |
35 | ---help--- | 98 | depends on MEDIA_SUPPORT |
36 | V4L core support for video capture and overlay devices, webcams and | 99 | depends on MEDIA_CAMERA_SUPPORT || MEDIA_ANALOG_TV_SUPPORT || MEDIA_RADIO_SUPPORT |
37 | AM/FM radio cards. | 100 | default y |
38 | |||
39 | This kernel includes support for the new Video for Linux Two API, | ||
40 | (V4L2). | ||
41 | |||
42 | Additional info and docs are available on the web at | ||
43 | <http://linuxtv.org> | ||
44 | |||
45 | Documentation for V4L2 is also available on the web at | ||
46 | <http://bytesex.org/v4l/>. | ||
47 | |||
48 | To compile this driver as a module, choose M here: the | ||
49 | module will be called videodev. | ||
50 | 101 | ||
51 | config VIDEO_V4L2_COMMON | 102 | config VIDEO_V4L2_COMMON |
52 | tristate | 103 | tristate |
@@ -64,25 +115,15 @@ config VIDEO_V4L2_SUBDEV_API | |||
64 | 115 | ||
65 | # | 116 | # |
66 | # DVB Core | 117 | # DVB Core |
118 | # Only enables if one of DTV is selected | ||
67 | # | 119 | # |
68 | 120 | ||
69 | config DVB_CORE | 121 | config DVB_CORE |
70 | tristate "DVB for Linux" | 122 | tristate |
123 | depends on MEDIA_SUPPORT | ||
124 | depends on MEDIA_DIGITAL_TV_SUPPORT | ||
125 | default y | ||
71 | select CRC32 | 126 | select CRC32 |
72 | help | ||
73 | DVB core utility functions for device handling, software fallbacks etc. | ||
74 | |||
75 | Enable this if you own a DVB/ATSC adapter and want to use it or if | ||
76 | you compile Linux for a digital SetTopBox. | ||
77 | |||
78 | Say Y when you have a DVB or an ATSC card and want to use it. | ||
79 | |||
80 | API specs and user tools are available from <http://www.linuxtv.org/>. | ||
81 | |||
82 | Please report problems regarding this support to the LinuxDVB | ||
83 | mailing list. | ||
84 | |||
85 | If unsure say N. | ||
86 | 127 | ||
87 | config DVB_NET | 128 | config DVB_NET |
88 | bool "DVB Network Support" | 129 | bool "DVB Network Support" |
@@ -97,12 +138,7 @@ config DVB_NET | |||
97 | You may want to disable the network support on embedded devices. If | 138 | You may want to disable the network support on embedded devices. If |
98 | unsure say Y. | 139 | unsure say Y. |
99 | 140 | ||
100 | config VIDEO_MEDIA | 141 | comment "Media drivers" |
101 | tristate | ||
102 | default (DVB_CORE && (VIDEO_DEV = n)) || (VIDEO_DEV && (DVB_CORE = n)) || (DVB_CORE && VIDEO_DEV) | ||
103 | |||
104 | comment "Multimedia drivers" | ||
105 | |||
106 | source "drivers/media/common/Kconfig" | 142 | source "drivers/media/common/Kconfig" |
107 | source "drivers/media/rc/Kconfig" | 143 | source "drivers/media/rc/Kconfig" |
108 | 144 | ||
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig index bbf4945149a9..94c6ff7a5da3 100644 --- a/drivers/media/common/tuners/Kconfig +++ b/drivers/media/common/tuners/Kconfig | |||
@@ -1,7 +1,8 @@ | |||
1 | config MEDIA_ATTACH | 1 | config MEDIA_ATTACH |
2 | bool "Load and attach frontend and tuner driver modules as needed" | 2 | bool "Load and attach frontend and tuner driver modules as needed" |
3 | depends on VIDEO_MEDIA | 3 | depends on MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT || MEDIA_RADIO_SUPPORT |
4 | depends on MODULES | 4 | depends on MODULES |
5 | default y if !EXPERT | ||
5 | help | 6 | help |
6 | Remove the static dependency of DVB card drivers on all | 7 | Remove the static dependency of DVB card drivers on all |
7 | frontend modules for all possible card variants. Instead, | 8 | frontend modules for all possible card variants. Instead, |
@@ -19,15 +20,15 @@ config MEDIA_ATTACH | |||
19 | 20 | ||
20 | config MEDIA_TUNER | 21 | config MEDIA_TUNER |
21 | tristate | 22 | tristate |
22 | default VIDEO_MEDIA && I2C | 23 | depends on (MEDIA_ANALOG_TV_SUPPORT || MEDIA_RADIO_SUPPORT) && I2C |
23 | depends on VIDEO_MEDIA && I2C | 24 | default y |
24 | select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE | 25 | select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMISE |
25 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMISE | 26 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMISE |
26 | select MEDIA_TUNER_XC4000 if !MEDIA_TUNER_CUSTOMISE | 27 | select MEDIA_TUNER_XC4000 if !MEDIA_TUNER_CUSTOMISE |
27 | select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMISE | 28 | select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMISE |
28 | select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE | 29 | select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMISE |
29 | select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMISE && EXPERIMENTAL | 30 | select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMISE && MEDIA_RADIO_SUPPORT && EXPERIMENTAL |
30 | select MEDIA_TUNER_TEA5767 if !MEDIA_TUNER_CUSTOMISE | 31 | select MEDIA_TUNER_TEA5767 if !MEDIA_TUNER_CUSTOMISE && MEDIA_RADIO_SUPPORT |
31 | select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMISE | 32 | select MEDIA_TUNER_SIMPLE if !MEDIA_TUNER_CUSTOMISE |
32 | select MEDIA_TUNER_TDA9887 if !MEDIA_TUNER_CUSTOMISE | 33 | select MEDIA_TUNER_TDA9887 if !MEDIA_TUNER_CUSTOMISE |
33 | select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE | 34 | select MEDIA_TUNER_MC44S803 if !MEDIA_TUNER_CUSTOMISE |
@@ -47,10 +48,11 @@ config MEDIA_TUNER_CUSTOMISE | |||
47 | 48 | ||
48 | menu "Customize TV tuners" | 49 | menu "Customize TV tuners" |
49 | visible if MEDIA_TUNER_CUSTOMISE | 50 | visible if MEDIA_TUNER_CUSTOMISE |
51 | depends on MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT || MEDIA_RADIO_SUPPORT | ||
50 | 52 | ||
51 | config MEDIA_TUNER_SIMPLE | 53 | config MEDIA_TUNER_SIMPLE |
52 | tristate "Simple tuner support" | 54 | tristate "Simple tuner support" |
53 | depends on VIDEO_MEDIA && I2C | 55 | depends on MEDIA_SUPPORT && I2C |
54 | select MEDIA_TUNER_TDA9887 | 56 | select MEDIA_TUNER_TDA9887 |
55 | default m if MEDIA_TUNER_CUSTOMISE | 57 | default m if MEDIA_TUNER_CUSTOMISE |
56 | help | 58 | help |
@@ -58,7 +60,7 @@ config MEDIA_TUNER_SIMPLE | |||
58 | 60 | ||
59 | config MEDIA_TUNER_TDA8290 | 61 | config MEDIA_TUNER_TDA8290 |
60 | tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" | 62 | tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" |
61 | depends on VIDEO_MEDIA && I2C | 63 | depends on MEDIA_SUPPORT && I2C |
62 | select MEDIA_TUNER_TDA827X | 64 | select MEDIA_TUNER_TDA827X |
63 | select MEDIA_TUNER_TDA18271 | 65 | select MEDIA_TUNER_TDA18271 |
64 | default m if MEDIA_TUNER_CUSTOMISE | 66 | default m if MEDIA_TUNER_CUSTOMISE |
@@ -67,21 +69,21 @@ config MEDIA_TUNER_TDA8290 | |||
67 | 69 | ||
68 | config MEDIA_TUNER_TDA827X | 70 | config MEDIA_TUNER_TDA827X |
69 | tristate "Philips TDA827X silicon tuner" | 71 | tristate "Philips TDA827X silicon tuner" |
70 | depends on VIDEO_MEDIA && I2C | 72 | depends on MEDIA_SUPPORT && I2C |
71 | default m if MEDIA_TUNER_CUSTOMISE | 73 | default m if MEDIA_TUNER_CUSTOMISE |
72 | help | 74 | help |
73 | A DVB-T silicon tuner module. Say Y when you want to support this tuner. | 75 | A DVB-T silicon tuner module. Say Y when you want to support this tuner. |
74 | 76 | ||
75 | config MEDIA_TUNER_TDA18271 | 77 | config MEDIA_TUNER_TDA18271 |
76 | tristate "NXP TDA18271 silicon tuner" | 78 | tristate "NXP TDA18271 silicon tuner" |
77 | depends on VIDEO_MEDIA && I2C | 79 | depends on MEDIA_SUPPORT && I2C |
78 | default m if MEDIA_TUNER_CUSTOMISE | 80 | default m if MEDIA_TUNER_CUSTOMISE |
79 | help | 81 | help |
80 | A silicon tuner module. Say Y when you want to support this tuner. | 82 | A silicon tuner module. Say Y when you want to support this tuner. |
81 | 83 | ||
82 | config MEDIA_TUNER_TDA9887 | 84 | config MEDIA_TUNER_TDA9887 |
83 | tristate "TDA 9885/6/7 analog IF demodulator" | 85 | tristate "TDA 9885/6/7 analog IF demodulator" |
84 | depends on VIDEO_MEDIA && I2C | 86 | depends on MEDIA_SUPPORT && I2C |
85 | default m if MEDIA_TUNER_CUSTOMISE | 87 | default m if MEDIA_TUNER_CUSTOMISE |
86 | help | 88 | help |
87 | Say Y here to include support for Philips TDA9885/6/7 | 89 | Say Y here to include support for Philips TDA9885/6/7 |
@@ -89,7 +91,7 @@ config MEDIA_TUNER_TDA9887 | |||
89 | 91 | ||
90 | config MEDIA_TUNER_TEA5761 | 92 | config MEDIA_TUNER_TEA5761 |
91 | tristate "TEA 5761 radio tuner (EXPERIMENTAL)" | 93 | tristate "TEA 5761 radio tuner (EXPERIMENTAL)" |
92 | depends on VIDEO_MEDIA && I2C | 94 | depends on MEDIA_SUPPORT && I2C |
93 | depends on EXPERIMENTAL | 95 | depends on EXPERIMENTAL |
94 | default m if MEDIA_TUNER_CUSTOMISE | 96 | default m if MEDIA_TUNER_CUSTOMISE |
95 | help | 97 | help |
@@ -97,63 +99,63 @@ config MEDIA_TUNER_TEA5761 | |||
97 | 99 | ||
98 | config MEDIA_TUNER_TEA5767 | 100 | config MEDIA_TUNER_TEA5767 |
99 | tristate "TEA 5767 radio tuner" | 101 | tristate "TEA 5767 radio tuner" |
100 | depends on VIDEO_MEDIA && I2C | 102 | depends on MEDIA_SUPPORT && I2C |
101 | default m if MEDIA_TUNER_CUSTOMISE | 103 | default m if MEDIA_TUNER_CUSTOMISE |
102 | help | 104 | help |
103 | Say Y here to include support for the Philips TEA5767 radio tuner. | 105 | Say Y here to include support for the Philips TEA5767 radio tuner. |
104 | 106 | ||
105 | config MEDIA_TUNER_MT20XX | 107 | config MEDIA_TUNER_MT20XX |
106 | tristate "Microtune 2032 / 2050 tuners" | 108 | tristate "Microtune 2032 / 2050 tuners" |
107 | depends on VIDEO_MEDIA && I2C | 109 | depends on MEDIA_SUPPORT && I2C |
108 | default m if MEDIA_TUNER_CUSTOMISE | 110 | default m if MEDIA_TUNER_CUSTOMISE |
109 | help | 111 | help |
110 | Say Y here to include support for the MT2032 / MT2050 tuner. | 112 | Say Y here to include support for the MT2032 / MT2050 tuner. |
111 | 113 | ||
112 | config MEDIA_TUNER_MT2060 | 114 | config MEDIA_TUNER_MT2060 |
113 | tristate "Microtune MT2060 silicon IF tuner" | 115 | tristate "Microtune MT2060 silicon IF tuner" |
114 | depends on VIDEO_MEDIA && I2C | 116 | depends on MEDIA_SUPPORT && I2C |
115 | default m if MEDIA_TUNER_CUSTOMISE | 117 | default m if MEDIA_TUNER_CUSTOMISE |
116 | help | 118 | help |
117 | A driver for the silicon IF tuner MT2060 from Microtune. | 119 | A driver for the silicon IF tuner MT2060 from Microtune. |
118 | 120 | ||
119 | config MEDIA_TUNER_MT2063 | 121 | config MEDIA_TUNER_MT2063 |
120 | tristate "Microtune MT2063 silicon IF tuner" | 122 | tristate "Microtune MT2063 silicon IF tuner" |
121 | depends on VIDEO_MEDIA && I2C | 123 | depends on MEDIA_SUPPORT && I2C |
122 | default m if MEDIA_TUNER_CUSTOMISE | 124 | default m if MEDIA_TUNER_CUSTOMISE |
123 | help | 125 | help |
124 | A driver for the silicon IF tuner MT2063 from Microtune. | 126 | A driver for the silicon IF tuner MT2063 from Microtune. |
125 | 127 | ||
126 | config MEDIA_TUNER_MT2266 | 128 | config MEDIA_TUNER_MT2266 |
127 | tristate "Microtune MT2266 silicon tuner" | 129 | tristate "Microtune MT2266 silicon tuner" |
128 | depends on VIDEO_MEDIA && I2C | 130 | depends on MEDIA_SUPPORT && I2C |
129 | default m if MEDIA_TUNER_CUSTOMISE | 131 | default m if MEDIA_TUNER_CUSTOMISE |
130 | help | 132 | help |
131 | A driver for the silicon baseband tuner MT2266 from Microtune. | 133 | A driver for the silicon baseband tuner MT2266 from Microtune. |
132 | 134 | ||
133 | config MEDIA_TUNER_MT2131 | 135 | config MEDIA_TUNER_MT2131 |
134 | tristate "Microtune MT2131 silicon tuner" | 136 | tristate "Microtune MT2131 silicon tuner" |
135 | depends on VIDEO_MEDIA && I2C | 137 | depends on MEDIA_SUPPORT && I2C |
136 | default m if MEDIA_TUNER_CUSTOMISE | 138 | default m if MEDIA_TUNER_CUSTOMISE |
137 | help | 139 | help |
138 | A driver for the silicon baseband tuner MT2131 from Microtune. | 140 | A driver for the silicon baseband tuner MT2131 from Microtune. |
139 | 141 | ||
140 | config MEDIA_TUNER_QT1010 | 142 | config MEDIA_TUNER_QT1010 |
141 | tristate "Quantek QT1010 silicon tuner" | 143 | tristate "Quantek QT1010 silicon tuner" |
142 | depends on VIDEO_MEDIA && I2C | 144 | depends on MEDIA_SUPPORT && I2C |
143 | default m if MEDIA_TUNER_CUSTOMISE | 145 | default m if MEDIA_TUNER_CUSTOMISE |
144 | help | 146 | help |
145 | A driver for the silicon tuner QT1010 from Quantek. | 147 | A driver for the silicon tuner QT1010 from Quantek. |
146 | 148 | ||
147 | config MEDIA_TUNER_XC2028 | 149 | config MEDIA_TUNER_XC2028 |
148 | tristate "XCeive xc2028/xc3028 tuners" | 150 | tristate "XCeive xc2028/xc3028 tuners" |
149 | depends on VIDEO_MEDIA && I2C | 151 | depends on MEDIA_SUPPORT && I2C |
150 | default m if MEDIA_TUNER_CUSTOMISE | 152 | default m if MEDIA_TUNER_CUSTOMISE |
151 | help | 153 | help |
152 | Say Y here to include support for the xc2028/xc3028 tuners. | 154 | Say Y here to include support for the xc2028/xc3028 tuners. |
153 | 155 | ||
154 | config MEDIA_TUNER_XC5000 | 156 | config MEDIA_TUNER_XC5000 |
155 | tristate "Xceive XC5000 silicon tuner" | 157 | tristate "Xceive XC5000 silicon tuner" |
156 | depends on VIDEO_MEDIA && I2C | 158 | depends on MEDIA_SUPPORT && I2C |
157 | default m if MEDIA_TUNER_CUSTOMISE | 159 | default m if MEDIA_TUNER_CUSTOMISE |
158 | help | 160 | help |
159 | A driver for the silicon tuner XC5000 from Xceive. | 161 | A driver for the silicon tuner XC5000 from Xceive. |
@@ -162,7 +164,7 @@ config MEDIA_TUNER_XC5000 | |||
162 | 164 | ||
163 | config MEDIA_TUNER_XC4000 | 165 | config MEDIA_TUNER_XC4000 |
164 | tristate "Xceive XC4000 silicon tuner" | 166 | tristate "Xceive XC4000 silicon tuner" |
165 | depends on VIDEO_MEDIA && I2C | 167 | depends on MEDIA_SUPPORT && I2C |
166 | default m if MEDIA_TUNER_CUSTOMISE | 168 | default m if MEDIA_TUNER_CUSTOMISE |
167 | help | 169 | help |
168 | A driver for the silicon tuner XC4000 from Xceive. | 170 | A driver for the silicon tuner XC4000 from Xceive. |
@@ -171,70 +173,70 @@ config MEDIA_TUNER_XC4000 | |||
171 | 173 | ||
172 | config MEDIA_TUNER_MXL5005S | 174 | config MEDIA_TUNER_MXL5005S |
173 | tristate "MaxLinear MSL5005S silicon tuner" | 175 | tristate "MaxLinear MSL5005S silicon tuner" |
174 | depends on VIDEO_MEDIA && I2C | 176 | depends on MEDIA_SUPPORT && I2C |
175 | default m if MEDIA_TUNER_CUSTOMISE | 177 | default m if MEDIA_TUNER_CUSTOMISE |
176 | help | 178 | help |
177 | A driver for the silicon tuner MXL5005S from MaxLinear. | 179 | A driver for the silicon tuner MXL5005S from MaxLinear. |
178 | 180 | ||
179 | config MEDIA_TUNER_MXL5007T | 181 | config MEDIA_TUNER_MXL5007T |
180 | tristate "MaxLinear MxL5007T silicon tuner" | 182 | tristate "MaxLinear MxL5007T silicon tuner" |
181 | depends on VIDEO_MEDIA && I2C | 183 | depends on MEDIA_SUPPORT && I2C |
182 | default m if MEDIA_TUNER_CUSTOMISE | 184 | default m if MEDIA_TUNER_CUSTOMISE |
183 | help | 185 | help |
184 | A driver for the silicon tuner MxL5007T from MaxLinear. | 186 | A driver for the silicon tuner MxL5007T from MaxLinear. |
185 | 187 | ||
186 | config MEDIA_TUNER_MC44S803 | 188 | config MEDIA_TUNER_MC44S803 |
187 | tristate "Freescale MC44S803 Low Power CMOS Broadband tuners" | 189 | tristate "Freescale MC44S803 Low Power CMOS Broadband tuners" |
188 | depends on VIDEO_MEDIA && I2C | 190 | depends on MEDIA_SUPPORT && I2C |
189 | default m if MEDIA_TUNER_CUSTOMISE | 191 | default m if MEDIA_TUNER_CUSTOMISE |
190 | help | 192 | help |
191 | Say Y here to support the Freescale MC44S803 based tuners | 193 | Say Y here to support the Freescale MC44S803 based tuners |
192 | 194 | ||
193 | config MEDIA_TUNER_MAX2165 | 195 | config MEDIA_TUNER_MAX2165 |
194 | tristate "Maxim MAX2165 silicon tuner" | 196 | tristate "Maxim MAX2165 silicon tuner" |
195 | depends on VIDEO_MEDIA && I2C | 197 | depends on MEDIA_SUPPORT && I2C |
196 | default m if MEDIA_TUNER_CUSTOMISE | 198 | default m if MEDIA_TUNER_CUSTOMISE |
197 | help | 199 | help |
198 | A driver for the silicon tuner MAX2165 from Maxim. | 200 | A driver for the silicon tuner MAX2165 from Maxim. |
199 | 201 | ||
200 | config MEDIA_TUNER_TDA18218 | 202 | config MEDIA_TUNER_TDA18218 |
201 | tristate "NXP TDA18218 silicon tuner" | 203 | tristate "NXP TDA18218 silicon tuner" |
202 | depends on VIDEO_MEDIA && I2C | 204 | depends on MEDIA_SUPPORT && I2C |
203 | default m if MEDIA_TUNER_CUSTOMISE | 205 | default m if MEDIA_TUNER_CUSTOMISE |
204 | help | 206 | help |
205 | NXP TDA18218 silicon tuner driver. | 207 | NXP TDA18218 silicon tuner driver. |
206 | 208 | ||
207 | config MEDIA_TUNER_FC0011 | 209 | config MEDIA_TUNER_FC0011 |
208 | tristate "Fitipower FC0011 silicon tuner" | 210 | tristate "Fitipower FC0011 silicon tuner" |
209 | depends on VIDEO_MEDIA && I2C | 211 | depends on MEDIA_SUPPORT && I2C |
210 | default m if MEDIA_TUNER_CUSTOMISE | 212 | default m if MEDIA_TUNER_CUSTOMISE |
211 | help | 213 | help |
212 | Fitipower FC0011 silicon tuner driver. | 214 | Fitipower FC0011 silicon tuner driver. |
213 | 215 | ||
214 | config MEDIA_TUNER_FC0012 | 216 | config MEDIA_TUNER_FC0012 |
215 | tristate "Fitipower FC0012 silicon tuner" | 217 | tristate "Fitipower FC0012 silicon tuner" |
216 | depends on VIDEO_MEDIA && I2C | 218 | depends on MEDIA_SUPPORT && I2C |
217 | default m if MEDIA_TUNER_CUSTOMISE | 219 | default m if MEDIA_TUNER_CUSTOMISE |
218 | help | 220 | help |
219 | Fitipower FC0012 silicon tuner driver. | 221 | Fitipower FC0012 silicon tuner driver. |
220 | 222 | ||
221 | config MEDIA_TUNER_FC0013 | 223 | config MEDIA_TUNER_FC0013 |
222 | tristate "Fitipower FC0013 silicon tuner" | 224 | tristate "Fitipower FC0013 silicon tuner" |
223 | depends on VIDEO_MEDIA && I2C | 225 | depends on MEDIA_SUPPORT && I2C |
224 | default m if MEDIA_TUNER_CUSTOMISE | 226 | default m if MEDIA_TUNER_CUSTOMISE |
225 | help | 227 | help |
226 | Fitipower FC0013 silicon tuner driver. | 228 | Fitipower FC0013 silicon tuner driver. |
227 | 229 | ||
228 | config MEDIA_TUNER_TDA18212 | 230 | config MEDIA_TUNER_TDA18212 |
229 | tristate "NXP TDA18212 silicon tuner" | 231 | tristate "NXP TDA18212 silicon tuner" |
230 | depends on VIDEO_MEDIA && I2C | 232 | depends on MEDIA_SUPPORT && I2C |
231 | default m if MEDIA_TUNER_CUSTOMISE | 233 | default m if MEDIA_TUNER_CUSTOMISE |
232 | help | 234 | help |
233 | NXP TDA18212 silicon tuner driver. | 235 | NXP TDA18212 silicon tuner driver. |
234 | 236 | ||
235 | config MEDIA_TUNER_TUA9001 | 237 | config MEDIA_TUNER_TUA9001 |
236 | tristate "Infineon TUA 9001 silicon tuner" | 238 | tristate "Infineon TUA 9001 silicon tuner" |
237 | depends on VIDEO_MEDIA && I2C | 239 | depends on MEDIA_SUPPORT && I2C |
238 | default m if MEDIA_TUNER_CUSTOMISE | 240 | default m if MEDIA_TUNER_CUSTOMISE |
239 | help | 241 | help |
240 | Infineon TUA 9001 silicon tuner driver. | 242 | Infineon TUA 9001 silicon tuner driver. |
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c index b5ee3ebfcfca..f88f948efee2 100644 --- a/drivers/media/common/tuners/tuner-xc2028.c +++ b/drivers/media/common/tuners/tuner-xc2028.c | |||
@@ -90,11 +90,22 @@ struct firmware_properties { | |||
90 | int scode_nr; | 90 | int scode_nr; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | enum xc2028_state { | ||
94 | XC2028_NO_FIRMWARE = 0, | ||
95 | XC2028_WAITING_FIRMWARE, | ||
96 | XC2028_ACTIVE, | ||
97 | XC2028_SLEEP, | ||
98 | XC2028_NODEV, | ||
99 | }; | ||
100 | |||
93 | struct xc2028_data { | 101 | struct xc2028_data { |
94 | struct list_head hybrid_tuner_instance_list; | 102 | struct list_head hybrid_tuner_instance_list; |
95 | struct tuner_i2c_props i2c_props; | 103 | struct tuner_i2c_props i2c_props; |
96 | __u32 frequency; | 104 | __u32 frequency; |
97 | 105 | ||
106 | enum xc2028_state state; | ||
107 | const char *fname; | ||
108 | |||
98 | struct firmware_description *firm; | 109 | struct firmware_description *firm; |
99 | int firm_size; | 110 | int firm_size; |
100 | __u16 firm_version; | 111 | __u16 firm_version; |
@@ -255,6 +266,21 @@ static v4l2_std_id parse_audio_std_option(void) | |||
255 | return 0; | 266 | return 0; |
256 | } | 267 | } |
257 | 268 | ||
269 | static int check_device_status(struct xc2028_data *priv) | ||
270 | { | ||
271 | switch (priv->state) { | ||
272 | case XC2028_NO_FIRMWARE: | ||
273 | case XC2028_WAITING_FIRMWARE: | ||
274 | return -EAGAIN; | ||
275 | case XC2028_ACTIVE: | ||
276 | case XC2028_SLEEP: | ||
277 | return 0; | ||
278 | case XC2028_NODEV: | ||
279 | return -ENODEV; | ||
280 | } | ||
281 | return 0; | ||
282 | } | ||
283 | |||
258 | static void free_firmware(struct xc2028_data *priv) | 284 | static void free_firmware(struct xc2028_data *priv) |
259 | { | 285 | { |
260 | int i; | 286 | int i; |
@@ -270,45 +296,28 @@ static void free_firmware(struct xc2028_data *priv) | |||
270 | 296 | ||
271 | priv->firm = NULL; | 297 | priv->firm = NULL; |
272 | priv->firm_size = 0; | 298 | priv->firm_size = 0; |
299 | priv->state = XC2028_NO_FIRMWARE; | ||
273 | 300 | ||
274 | memset(&priv->cur_fw, 0, sizeof(priv->cur_fw)); | 301 | memset(&priv->cur_fw, 0, sizeof(priv->cur_fw)); |
275 | } | 302 | } |
276 | 303 | ||
277 | static int load_all_firmwares(struct dvb_frontend *fe) | 304 | static int load_all_firmwares(struct dvb_frontend *fe, |
305 | const struct firmware *fw) | ||
278 | { | 306 | { |
279 | struct xc2028_data *priv = fe->tuner_priv; | 307 | struct xc2028_data *priv = fe->tuner_priv; |
280 | const struct firmware *fw = NULL; | ||
281 | const unsigned char *p, *endp; | 308 | const unsigned char *p, *endp; |
282 | int rc = 0; | 309 | int rc = 0; |
283 | int n, n_array; | 310 | int n, n_array; |
284 | char name[33]; | 311 | char name[33]; |
285 | char *fname; | ||
286 | 312 | ||
287 | tuner_dbg("%s called\n", __func__); | 313 | tuner_dbg("%s called\n", __func__); |
288 | 314 | ||
289 | if (!firmware_name[0]) | ||
290 | fname = priv->ctrl.fname; | ||
291 | else | ||
292 | fname = firmware_name; | ||
293 | |||
294 | tuner_dbg("Reading firmware %s\n", fname); | ||
295 | rc = request_firmware(&fw, fname, priv->i2c_props.adap->dev.parent); | ||
296 | if (rc < 0) { | ||
297 | if (rc == -ENOENT) | ||
298 | tuner_err("Error: firmware %s not found.\n", | ||
299 | fname); | ||
300 | else | ||
301 | tuner_err("Error %d while requesting firmware %s \n", | ||
302 | rc, fname); | ||
303 | |||
304 | return rc; | ||
305 | } | ||
306 | p = fw->data; | 315 | p = fw->data; |
307 | endp = p + fw->size; | 316 | endp = p + fw->size; |
308 | 317 | ||
309 | if (fw->size < sizeof(name) - 1 + 2 + 2) { | 318 | if (fw->size < sizeof(name) - 1 + 2 + 2) { |
310 | tuner_err("Error: firmware file %s has invalid size!\n", | 319 | tuner_err("Error: firmware file %s has invalid size!\n", |
311 | fname); | 320 | priv->fname); |
312 | goto corrupt; | 321 | goto corrupt; |
313 | } | 322 | } |
314 | 323 | ||
@@ -323,7 +332,7 @@ static int load_all_firmwares(struct dvb_frontend *fe) | |||
323 | p += 2; | 332 | p += 2; |
324 | 333 | ||
325 | tuner_info("Loading %d firmware images from %s, type: %s, ver %d.%d\n", | 334 | tuner_info("Loading %d firmware images from %s, type: %s, ver %d.%d\n", |
326 | n_array, fname, name, | 335 | n_array, priv->fname, name, |
327 | priv->firm_version >> 8, priv->firm_version & 0xff); | 336 | priv->firm_version >> 8, priv->firm_version & 0xff); |
328 | 337 | ||
329 | priv->firm = kcalloc(n_array, sizeof(*priv->firm), GFP_KERNEL); | 338 | priv->firm = kcalloc(n_array, sizeof(*priv->firm), GFP_KERNEL); |
@@ -417,9 +426,10 @@ err: | |||
417 | free_firmware(priv); | 426 | free_firmware(priv); |
418 | 427 | ||
419 | done: | 428 | done: |
420 | release_firmware(fw); | ||
421 | if (rc == 0) | 429 | if (rc == 0) |
422 | tuner_dbg("Firmware files loaded.\n"); | 430 | tuner_dbg("Firmware files loaded.\n"); |
431 | else | ||
432 | priv->state = XC2028_NODEV; | ||
423 | 433 | ||
424 | return rc; | 434 | return rc; |
425 | } | 435 | } |
@@ -707,22 +717,15 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type, | |||
707 | { | 717 | { |
708 | struct xc2028_data *priv = fe->tuner_priv; | 718 | struct xc2028_data *priv = fe->tuner_priv; |
709 | struct firmware_properties new_fw; | 719 | struct firmware_properties new_fw; |
710 | int rc = 0, retry_count = 0; | 720 | int rc, retry_count = 0; |
711 | u16 version, hwmodel; | 721 | u16 version, hwmodel; |
712 | v4l2_std_id std0; | 722 | v4l2_std_id std0; |
713 | 723 | ||
714 | tuner_dbg("%s called\n", __func__); | 724 | tuner_dbg("%s called\n", __func__); |
715 | 725 | ||
716 | if (!priv->firm) { | 726 | rc = check_device_status(priv); |
717 | if (!priv->ctrl.fname) { | 727 | if (rc < 0) |
718 | tuner_info("xc2028/3028 firmware name not set!\n"); | 728 | return rc; |
719 | return -EINVAL; | ||
720 | } | ||
721 | |||
722 | rc = load_all_firmwares(fe); | ||
723 | if (rc < 0) | ||
724 | return rc; | ||
725 | } | ||
726 | 729 | ||
727 | if (priv->ctrl.mts && !(type & FM)) | 730 | if (priv->ctrl.mts && !(type & FM)) |
728 | type |= MTS; | 731 | type |= MTS; |
@@ -749,9 +752,13 @@ retry: | |||
749 | printk("scode_nr %d\n", new_fw.scode_nr); | 752 | printk("scode_nr %d\n", new_fw.scode_nr); |
750 | } | 753 | } |
751 | 754 | ||
752 | /* No need to reload base firmware if it matches */ | 755 | /* |
753 | if (((BASE | new_fw.type) & BASE_TYPES) == | 756 | * No need to reload base firmware if it matches and if the tuner |
754 | (priv->cur_fw.type & BASE_TYPES)) { | 757 | * is not at sleep mode |
758 | */ | ||
759 | if ((priv->state = XC2028_ACTIVE) && | ||
760 | (((BASE | new_fw.type) & BASE_TYPES) == | ||
761 | (priv->cur_fw.type & BASE_TYPES))) { | ||
755 | tuner_dbg("BASE firmware not changed.\n"); | 762 | tuner_dbg("BASE firmware not changed.\n"); |
756 | goto skip_base; | 763 | goto skip_base; |
757 | } | 764 | } |
@@ -872,10 +879,13 @@ read_not_reliable: | |||
872 | * 2. Tell whether BASE firmware was just changed the next time through. | 879 | * 2. Tell whether BASE firmware was just changed the next time through. |
873 | */ | 880 | */ |
874 | priv->cur_fw.type |= BASE; | 881 | priv->cur_fw.type |= BASE; |
882 | priv->state = XC2028_ACTIVE; | ||
875 | 883 | ||
876 | return 0; | 884 | return 0; |
877 | 885 | ||
878 | fail: | 886 | fail: |
887 | priv->state = XC2028_SLEEP; | ||
888 | |||
879 | memset(&priv->cur_fw, 0, sizeof(priv->cur_fw)); | 889 | memset(&priv->cur_fw, 0, sizeof(priv->cur_fw)); |
880 | if (retry_count < 8) { | 890 | if (retry_count < 8) { |
881 | msleep(50); | 891 | msleep(50); |
@@ -893,28 +903,39 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) | |||
893 | { | 903 | { |
894 | struct xc2028_data *priv = fe->tuner_priv; | 904 | struct xc2028_data *priv = fe->tuner_priv; |
895 | u16 frq_lock, signal = 0; | 905 | u16 frq_lock, signal = 0; |
896 | int rc; | 906 | int rc, i; |
897 | 907 | ||
898 | tuner_dbg("%s called\n", __func__); | 908 | tuner_dbg("%s called\n", __func__); |
899 | 909 | ||
910 | rc = check_device_status(priv); | ||
911 | if (rc < 0) | ||
912 | return rc; | ||
913 | |||
900 | mutex_lock(&priv->lock); | 914 | mutex_lock(&priv->lock); |
901 | 915 | ||
902 | /* Sync Lock Indicator */ | 916 | /* Sync Lock Indicator */ |
903 | rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock); | 917 | for (i = 0; i < 3; i++) { |
904 | if (rc < 0) | 918 | rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock); |
905 | goto ret; | 919 | if (rc < 0) |
920 | goto ret; | ||
906 | 921 | ||
907 | /* Frequency is locked */ | 922 | if (frq_lock) |
908 | if (frq_lock == 1) | 923 | break; |
909 | signal = 1 << 11; | 924 | msleep(6); |
925 | } | ||
926 | |||
927 | /* Frequency didn't lock */ | ||
928 | if (frq_lock == 2) | ||
929 | goto ret; | ||
910 | 930 | ||
911 | /* Get SNR of the video signal */ | 931 | /* Get SNR of the video signal */ |
912 | rc = xc2028_get_reg(priv, XREG_SNR, &signal); | 932 | rc = xc2028_get_reg(priv, XREG_SNR, &signal); |
913 | if (rc < 0) | 933 | if (rc < 0) |
914 | goto ret; | 934 | goto ret; |
915 | 935 | ||
916 | /* Use both frq_lock and signal to generate the result */ | 936 | /* Signal level is 3 bits only */ |
917 | signal = signal || ((signal & 0x07) << 12); | 937 | |
938 | signal = ((1 << 12) - 1) | ((signal & 0x07) << 12); | ||
918 | 939 | ||
919 | ret: | 940 | ret: |
920 | mutex_unlock(&priv->lock); | 941 | mutex_unlock(&priv->lock); |
@@ -926,6 +947,49 @@ ret: | |||
926 | return rc; | 947 | return rc; |
927 | } | 948 | } |
928 | 949 | ||
950 | static int xc2028_get_afc(struct dvb_frontend *fe, s32 *afc) | ||
951 | { | ||
952 | struct xc2028_data *priv = fe->tuner_priv; | ||
953 | int i, rc; | ||
954 | u16 frq_lock = 0; | ||
955 | s16 afc_reg = 0; | ||
956 | |||
957 | rc = check_device_status(priv); | ||
958 | if (rc < 0) | ||
959 | return rc; | ||
960 | |||
961 | mutex_lock(&priv->lock); | ||
962 | |||
963 | /* Sync Lock Indicator */ | ||
964 | for (i = 0; i < 3; i++) { | ||
965 | rc = xc2028_get_reg(priv, XREG_LOCK, &frq_lock); | ||
966 | if (rc < 0) | ||
967 | goto ret; | ||
968 | |||
969 | if (frq_lock) | ||
970 | break; | ||
971 | msleep(6); | ||
972 | } | ||
973 | |||
974 | /* Frequency didn't lock */ | ||
975 | if (frq_lock == 2) | ||
976 | goto ret; | ||
977 | |||
978 | /* Get AFC */ | ||
979 | rc = xc2028_get_reg(priv, XREG_FREQ_ERROR, &afc_reg); | ||
980 | if (rc < 0) | ||
981 | return rc; | ||
982 | |||
983 | *afc = afc_reg * 15625; /* Hz */ | ||
984 | |||
985 | tuner_dbg("AFC is %d Hz\n", *afc); | ||
986 | |||
987 | ret: | ||
988 | mutex_unlock(&priv->lock); | ||
989 | |||
990 | return rc; | ||
991 | } | ||
992 | |||
929 | #define DIV 15625 | 993 | #define DIV 15625 |
930 | 994 | ||
931 | static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */, | 995 | static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */, |
@@ -1111,11 +1175,16 @@ static int xc2028_set_params(struct dvb_frontend *fe) | |||
1111 | u32 delsys = c->delivery_system; | 1175 | u32 delsys = c->delivery_system; |
1112 | u32 bw = c->bandwidth_hz; | 1176 | u32 bw = c->bandwidth_hz; |
1113 | struct xc2028_data *priv = fe->tuner_priv; | 1177 | struct xc2028_data *priv = fe->tuner_priv; |
1114 | unsigned int type=0; | 1178 | int rc; |
1179 | unsigned int type = 0; | ||
1115 | u16 demod = 0; | 1180 | u16 demod = 0; |
1116 | 1181 | ||
1117 | tuner_dbg("%s called\n", __func__); | 1182 | tuner_dbg("%s called\n", __func__); |
1118 | 1183 | ||
1184 | rc = check_device_status(priv); | ||
1185 | if (rc < 0) | ||
1186 | return rc; | ||
1187 | |||
1119 | switch (delsys) { | 1188 | switch (delsys) { |
1120 | case SYS_DVBT: | 1189 | case SYS_DVBT: |
1121 | case SYS_DVBT2: | 1190 | case SYS_DVBT2: |
@@ -1201,7 +1270,11 @@ static int xc2028_set_params(struct dvb_frontend *fe) | |||
1201 | static int xc2028_sleep(struct dvb_frontend *fe) | 1270 | static int xc2028_sleep(struct dvb_frontend *fe) |
1202 | { | 1271 | { |
1203 | struct xc2028_data *priv = fe->tuner_priv; | 1272 | struct xc2028_data *priv = fe->tuner_priv; |
1204 | int rc = 0; | 1273 | int rc; |
1274 | |||
1275 | rc = check_device_status(priv); | ||
1276 | if (rc < 0) | ||
1277 | return rc; | ||
1205 | 1278 | ||
1206 | /* Avoid firmware reload on slow devices or if PM disabled */ | 1279 | /* Avoid firmware reload on slow devices or if PM disabled */ |
1207 | if (no_poweroff || priv->ctrl.disable_power_mgmt) | 1280 | if (no_poweroff || priv->ctrl.disable_power_mgmt) |
@@ -1220,7 +1293,7 @@ static int xc2028_sleep(struct dvb_frontend *fe) | |||
1220 | else | 1293 | else |
1221 | rc = send_seq(priv, {0x80, XREG_POWER_DOWN, 0x00, 0x00}); | 1294 | rc = send_seq(priv, {0x80, XREG_POWER_DOWN, 0x00, 0x00}); |
1222 | 1295 | ||
1223 | priv->cur_fw.type = 0; /* need firmware reload */ | 1296 | priv->state = XC2028_SLEEP; |
1224 | 1297 | ||
1225 | mutex_unlock(&priv->lock); | 1298 | mutex_unlock(&priv->lock); |
1226 | 1299 | ||
@@ -1237,8 +1310,9 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) | |||
1237 | 1310 | ||
1238 | /* only perform final cleanup if this is the last instance */ | 1311 | /* only perform final cleanup if this is the last instance */ |
1239 | if (hybrid_tuner_report_instance_count(priv) == 1) { | 1312 | if (hybrid_tuner_report_instance_count(priv) == 1) { |
1240 | kfree(priv->ctrl.fname); | ||
1241 | free_firmware(priv); | 1313 | free_firmware(priv); |
1314 | kfree(priv->ctrl.fname); | ||
1315 | priv->ctrl.fname = NULL; | ||
1242 | } | 1316 | } |
1243 | 1317 | ||
1244 | if (priv) | 1318 | if (priv) |
@@ -1254,14 +1328,42 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) | |||
1254 | static int xc2028_get_frequency(struct dvb_frontend *fe, u32 *frequency) | 1328 | static int xc2028_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
1255 | { | 1329 | { |
1256 | struct xc2028_data *priv = fe->tuner_priv; | 1330 | struct xc2028_data *priv = fe->tuner_priv; |
1331 | int rc; | ||
1257 | 1332 | ||
1258 | tuner_dbg("%s called\n", __func__); | 1333 | tuner_dbg("%s called\n", __func__); |
1259 | 1334 | ||
1335 | rc = check_device_status(priv); | ||
1336 | if (rc < 0) | ||
1337 | return rc; | ||
1338 | |||
1260 | *frequency = priv->frequency; | 1339 | *frequency = priv->frequency; |
1261 | 1340 | ||
1262 | return 0; | 1341 | return 0; |
1263 | } | 1342 | } |
1264 | 1343 | ||
1344 | static void load_firmware_cb(const struct firmware *fw, | ||
1345 | void *context) | ||
1346 | { | ||
1347 | struct dvb_frontend *fe = context; | ||
1348 | struct xc2028_data *priv = fe->tuner_priv; | ||
1349 | int rc; | ||
1350 | |||
1351 | tuner_dbg("request_firmware_nowait(): %s\n", fw ? "OK" : "error"); | ||
1352 | if (!fw) { | ||
1353 | tuner_err("Could not load firmware %s.\n", priv->fname); | ||
1354 | priv->state = XC2028_NODEV; | ||
1355 | return; | ||
1356 | } | ||
1357 | |||
1358 | rc = load_all_firmwares(fe, fw); | ||
1359 | |||
1360 | release_firmware(fw); | ||
1361 | |||
1362 | if (rc < 0) | ||
1363 | return; | ||
1364 | priv->state = XC2028_SLEEP; | ||
1365 | } | ||
1366 | |||
1265 | static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg) | 1367 | static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg) |
1266 | { | 1368 | { |
1267 | struct xc2028_data *priv = fe->tuner_priv; | 1369 | struct xc2028_data *priv = fe->tuner_priv; |
@@ -1272,21 +1374,49 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg) | |||
1272 | 1374 | ||
1273 | mutex_lock(&priv->lock); | 1375 | mutex_lock(&priv->lock); |
1274 | 1376 | ||
1377 | /* | ||
1378 | * Copy the config data. | ||
1379 | * For the firmware name, keep a local copy of the string, | ||
1380 | * in order to avoid troubles during device release. | ||
1381 | */ | ||
1382 | if (priv->ctrl.fname) | ||
1383 | kfree(priv->ctrl.fname); | ||
1275 | memcpy(&priv->ctrl, p, sizeof(priv->ctrl)); | 1384 | memcpy(&priv->ctrl, p, sizeof(priv->ctrl)); |
1276 | if (priv->ctrl.max_len < 9) | ||
1277 | priv->ctrl.max_len = 13; | ||
1278 | |||
1279 | if (p->fname) { | 1385 | if (p->fname) { |
1280 | if (priv->ctrl.fname && strcmp(p->fname, priv->ctrl.fname)) { | ||
1281 | kfree(priv->ctrl.fname); | ||
1282 | free_firmware(priv); | ||
1283 | } | ||
1284 | |||
1285 | priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL); | 1386 | priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL); |
1286 | if (priv->ctrl.fname == NULL) | 1387 | if (priv->ctrl.fname == NULL) |
1287 | rc = -ENOMEM; | 1388 | rc = -ENOMEM; |
1288 | } | 1389 | } |
1289 | 1390 | ||
1391 | /* | ||
1392 | * If firmware name changed, frees firmware. As free_firmware will | ||
1393 | * reset the status to NO_FIRMWARE, this forces a new request_firmware | ||
1394 | */ | ||
1395 | if (!firmware_name[0] && p->fname && | ||
1396 | priv->fname && strcmp(p->fname, priv->fname)) | ||
1397 | free_firmware(priv); | ||
1398 | |||
1399 | if (priv->ctrl.max_len < 9) | ||
1400 | priv->ctrl.max_len = 13; | ||
1401 | |||
1402 | if (priv->state == XC2028_NO_FIRMWARE) { | ||
1403 | if (!firmware_name[0]) | ||
1404 | priv->fname = priv->ctrl.fname; | ||
1405 | else | ||
1406 | priv->fname = firmware_name; | ||
1407 | |||
1408 | rc = request_firmware_nowait(THIS_MODULE, 1, | ||
1409 | priv->fname, | ||
1410 | priv->i2c_props.adap->dev.parent, | ||
1411 | GFP_KERNEL, | ||
1412 | fe, load_firmware_cb); | ||
1413 | if (rc < 0) { | ||
1414 | tuner_err("Failed to request firmware %s\n", | ||
1415 | priv->fname); | ||
1416 | priv->state = XC2028_NODEV; | ||
1417 | } | ||
1418 | priv->state = XC2028_WAITING_FIRMWARE; | ||
1419 | } | ||
1290 | mutex_unlock(&priv->lock); | 1420 | mutex_unlock(&priv->lock); |
1291 | 1421 | ||
1292 | return rc; | 1422 | return rc; |
@@ -1305,6 +1435,7 @@ static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = { | |||
1305 | .release = xc2028_dvb_release, | 1435 | .release = xc2028_dvb_release, |
1306 | .get_frequency = xc2028_get_frequency, | 1436 | .get_frequency = xc2028_get_frequency, |
1307 | .get_rf_strength = xc2028_signal, | 1437 | .get_rf_strength = xc2028_signal, |
1438 | .get_afc = xc2028_get_afc, | ||
1308 | .set_params = xc2028_set_params, | 1439 | .set_params = xc2028_set_params, |
1309 | .sleep = xc2028_sleep, | 1440 | .sleep = xc2028_sleep, |
1310 | }; | 1441 | }; |
@@ -1375,3 +1506,5 @@ MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver"); | |||
1375 | MODULE_AUTHOR("Michel Ludwig <michel.ludwig@gmail.com>"); | 1506 | MODULE_AUTHOR("Michel Ludwig <michel.ludwig@gmail.com>"); |
1376 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); | 1507 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
1377 | MODULE_LICENSE("GPL"); | 1508 | MODULE_LICENSE("GPL"); |
1509 | MODULE_FIRMWARE(XC2028_DEFAULT_FIRMWARE); | ||
1510 | MODULE_FIRMWARE(XC3028L_DEFAULT_FIRMWARE); | ||
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index dcca42ca57be..bac8009e1d49 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c | |||
@@ -717,6 +717,12 @@ static int xc5000_set_params(struct dvb_frontend *fe) | |||
717 | priv->freq_hz = freq - 1750000; | 717 | priv->freq_hz = freq - 1750000; |
718 | priv->video_standard = DTV6; | 718 | priv->video_standard = DTV6; |
719 | break; | 719 | break; |
720 | case SYS_ISDBT: | ||
721 | /* All ISDB-T are currently for 6 MHz bw */ | ||
722 | if (!bw) | ||
723 | bw = 6000000; | ||
724 | /* fall to OFDM handling */ | ||
725 | case SYS_DMBTH: | ||
720 | case SYS_DVBT: | 726 | case SYS_DVBT: |
721 | case SYS_DVBT2: | 727 | case SYS_DVBT2: |
722 | dprintk(1, "%s() OFDM\n", __func__); | 728 | dprintk(1, "%s() OFDM\n", __func__); |
diff --git a/drivers/media/dvb/ddbridge/ddbridge-core.c b/drivers/media/dvb/ddbridge/ddbridge-core.c index 131b938e9e81..ebf3f05839d2 100644 --- a/drivers/media/dvb/ddbridge/ddbridge-core.c +++ b/drivers/media/dvb/ddbridge/ddbridge-core.c | |||
@@ -578,6 +578,7 @@ static int demod_attach_drxk(struct ddb_input *input) | |||
578 | 578 | ||
579 | memset(&config, 0, sizeof(config)); | 579 | memset(&config, 0, sizeof(config)); |
580 | config.microcode_name = "drxk_a3.mc"; | 580 | config.microcode_name = "drxk_a3.mc"; |
581 | config.qam_demod_parameter_count = 4; | ||
581 | config.adr = 0x29 + (input->nr & 1); | 582 | config.adr = 0x29 + (input->nr & 1); |
582 | 583 | ||
583 | fe = input->fe = dvb_attach(drxk_attach, &config, i2c); | 584 | fe = input->fe = dvb_attach(drxk_attach, &config, i2c); |
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h index e929d5697b87..7c64c09103a9 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/drivers/media/dvb/dvb-core/dvb_frontend.h | |||
@@ -220,6 +220,7 @@ struct dvb_tuner_ops { | |||
220 | #define TUNER_STATUS_STEREO 2 | 220 | #define TUNER_STATUS_STEREO 2 |
221 | int (*get_status)(struct dvb_frontend *fe, u32 *status); | 221 | int (*get_status)(struct dvb_frontend *fe, u32 *status); |
222 | int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength); | 222 | int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength); |
223 | int (*get_afc)(struct dvb_frontend *fe, s32 *afc); | ||
223 | 224 | ||
224 | /** These are provided separately from set_params in order to facilitate silicon | 225 | /** These are provided separately from set_params in order to facilitate silicon |
225 | * tuners which require sophisticated tuning loops, controlling each parameter separately. */ | 226 | * tuners which require sophisticated tuning loops, controlling each parameter separately. */ |
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index a26949336b3d..c2161565023a 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -418,9 +418,12 @@ config DVB_USB_RTL28XXU | |||
418 | tristate "Realtek RTL28xxU DVB USB support" | 418 | tristate "Realtek RTL28xxU DVB USB support" |
419 | depends on DVB_USB && EXPERIMENTAL | 419 | depends on DVB_USB && EXPERIMENTAL |
420 | select DVB_RTL2830 | 420 | select DVB_RTL2830 |
421 | select DVB_RTL2832 | ||
421 | select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE | 422 | select MEDIA_TUNER_QT1010 if !MEDIA_TUNER_CUSTOMISE |
422 | select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE | 423 | select MEDIA_TUNER_MT2060 if !MEDIA_TUNER_CUSTOMISE |
423 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE | 424 | select MEDIA_TUNER_MXL5005S if !MEDIA_TUNER_CUSTOMISE |
425 | select MEDIA_TUNER_FC0012 if !MEDIA_TUNER_CUSTOMISE | ||
426 | select MEDIA_TUNER_FC0013 if !MEDIA_TUNER_CUSTOMISE | ||
424 | help | 427 | help |
425 | Say Y here to support the Realtek RTL28xxU DVB USB receiver. | 428 | Say Y here to support the Realtek RTL28xxU DVB USB receiver. |
426 | 429 | ||
diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c index 4008b9c50fbd..8ffcad000ad3 100644 --- a/drivers/media/dvb/dvb-usb/az6007.c +++ b/drivers/media/dvb/dvb-usb/az6007.c | |||
@@ -593,9 +593,7 @@ static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6]) | |||
593 | memcpy(mac, st->data, sizeof(mac)); | 593 | memcpy(mac, st->data, sizeof(mac)); |
594 | 594 | ||
595 | if (ret > 0) | 595 | if (ret > 0) |
596 | deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n", | 596 | deb_info("%s: mac is %pM\n", __func__, mac); |
597 | __func__, mac[0], mac[1], mac[2], | ||
598 | mac[3], mac[4], mac[5]); | ||
599 | 597 | ||
600 | return ret; | 598 | return ret; |
601 | } | 599 | } |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 7a6160bf54ba..26c44818a5ab 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -100,6 +100,7 @@ | |||
100 | #define USB_PID_CONCEPTRONIC_CTVDIGRCU 0xe397 | 100 | #define USB_PID_CONCEPTRONIC_CTVDIGRCU 0xe397 |
101 | #define USB_PID_CONEXANT_D680_DMB 0x86d6 | 101 | #define USB_PID_CONEXANT_D680_DMB 0x86d6 |
102 | #define USB_PID_CREATIX_CTX1921 0x1921 | 102 | #define USB_PID_CREATIX_CTX1921 0x1921 |
103 | #define USB_PID_DELOCK_USB2_DVBT 0xb803 | ||
103 | #define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064 | 104 | #define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064 |
104 | #define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065 | 105 | #define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065 |
105 | #define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8 | 106 | #define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8 |
@@ -160,6 +161,7 @@ | |||
160 | #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 | 161 | #define USB_PID_TERRATEC_CINERGY_T_STICK 0x0093 |
161 | #define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097 | 162 | #define USB_PID_TERRATEC_CINERGY_T_STICK_RC 0x0097 |
162 | #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 | 163 | #define USB_PID_TERRATEC_CINERGY_T_STICK_DUAL_RC 0x0099 |
164 | #define USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1 0x00a9 | ||
163 | #define USB_PID_TWINHAN_VP7041_COLD 0x3201 | 165 | #define USB_PID_TWINHAN_VP7041_COLD 0x3201 |
164 | #define USB_PID_TWINHAN_VP7041_WARM 0x3202 | 166 | #define USB_PID_TWINHAN_VP7041_WARM 0x3202 |
165 | #define USB_PID_TWINHAN_VP7020_COLD 0x3203 | 167 | #define USB_PID_TWINHAN_VP7020_COLD 0x3203 |
@@ -245,6 +247,7 @@ | |||
245 | #define USB_PID_TERRATEC_H7_2 0x10a3 | 247 | #define USB_PID_TERRATEC_H7_2 0x10a3 |
246 | #define USB_PID_TERRATEC_T3 0x10a0 | 248 | #define USB_PID_TERRATEC_T3 0x10a0 |
247 | #define USB_PID_TERRATEC_T5 0x10a1 | 249 | #define USB_PID_TERRATEC_T5 0x10a1 |
250 | #define USB_PID_NOXON_DAB_STICK 0x00b3 | ||
248 | #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e | 251 | #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e |
249 | #define USB_PID_PINNACLE_PCTV2000E 0x022c | 252 | #define USB_PID_PINNACLE_PCTV2000E 0x022c |
250 | #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 | 253 | #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 |
diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 41e1f5537f44..6bd0bd792437 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2009 Antti Palosaari <crope@iki.fi> | 4 | * Copyright (C) 2009 Antti Palosaari <crope@iki.fi> |
5 | * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> | 5 | * Copyright (C) 2011 Antti Palosaari <crope@iki.fi> |
6 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@googlemail.com> | ||
6 | * | 7 | * |
7 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
@@ -22,10 +23,13 @@ | |||
22 | #include "rtl28xxu.h" | 23 | #include "rtl28xxu.h" |
23 | 24 | ||
24 | #include "rtl2830.h" | 25 | #include "rtl2830.h" |
26 | #include "rtl2832.h" | ||
25 | 27 | ||
26 | #include "qt1010.h" | 28 | #include "qt1010.h" |
27 | #include "mt2060.h" | 29 | #include "mt2060.h" |
28 | #include "mxl5005s.h" | 30 | #include "mxl5005s.h" |
31 | #include "fc0012.h" | ||
32 | #include "fc0013.h" | ||
29 | 33 | ||
30 | /* debug */ | 34 | /* debug */ |
31 | static int dvb_usb_rtl28xxu_debug; | 35 | static int dvb_usb_rtl28xxu_debug; |
@@ -80,7 +84,7 @@ err: | |||
80 | return ret; | 84 | return ret; |
81 | } | 85 | } |
82 | 86 | ||
83 | static int rtl2831_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) | 87 | static int rtl28xx_wr_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) |
84 | { | 88 | { |
85 | struct rtl28xxu_req req; | 89 | struct rtl28xxu_req req; |
86 | 90 | ||
@@ -116,12 +120,12 @@ static int rtl2831_rd_regs(struct dvb_usb_device *d, u16 reg, u8 *val, int len) | |||
116 | return rtl28xxu_ctrl_msg(d, &req); | 120 | return rtl28xxu_ctrl_msg(d, &req); |
117 | } | 121 | } |
118 | 122 | ||
119 | static int rtl2831_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) | 123 | static int rtl28xx_wr_reg(struct dvb_usb_device *d, u16 reg, u8 val) |
120 | { | 124 | { |
121 | return rtl2831_wr_regs(d, reg, &val, 1); | 125 | return rtl28xx_wr_regs(d, reg, &val, 1); |
122 | } | 126 | } |
123 | 127 | ||
124 | static int rtl2831_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) | 128 | static int rtl28xx_rd_reg(struct dvb_usb_device *d, u16 reg, u8 *val) |
125 | { | 129 | { |
126 | return rtl2831_rd_regs(d, reg, val, 1); | 130 | return rtl2831_rd_regs(d, reg, val, 1); |
127 | } | 131 | } |
@@ -308,12 +312,12 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) | |||
308 | */ | 312 | */ |
309 | 313 | ||
310 | /* GPIO direction */ | 314 | /* GPIO direction */ |
311 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_DIR, 0x0a); | 315 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_DIR, 0x0a); |
312 | if (ret) | 316 | if (ret) |
313 | goto err; | 317 | goto err; |
314 | 318 | ||
315 | /* enable as output GPIO0, GPIO2, GPIO4 */ | 319 | /* enable as output GPIO0, GPIO2, GPIO4 */ |
316 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_OUT_EN, 0x15); | 320 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_OUT_EN, 0x15); |
317 | if (ret) | 321 | if (ret) |
318 | goto err; | 322 | goto err; |
319 | 323 | ||
@@ -381,34 +385,159 @@ err: | |||
381 | return ret; | 385 | return ret; |
382 | } | 386 | } |
383 | 387 | ||
388 | static struct rtl2832_config rtl28xxu_rtl2832_fc0012_config = { | ||
389 | .i2c_addr = 0x10, /* 0x20 */ | ||
390 | .xtal = 28800000, | ||
391 | .if_dvbt = 0, | ||
392 | .tuner = TUNER_RTL2832_FC0012 | ||
393 | }; | ||
394 | |||
395 | static struct rtl2832_config rtl28xxu_rtl2832_fc0013_config = { | ||
396 | .i2c_addr = 0x10, /* 0x20 */ | ||
397 | .xtal = 28800000, | ||
398 | .if_dvbt = 0, | ||
399 | .tuner = TUNER_RTL2832_FC0013 | ||
400 | }; | ||
401 | |||
402 | static int rtl2832u_fc0012_tuner_callback(struct dvb_usb_device *d, | ||
403 | int cmd, int arg) | ||
404 | { | ||
405 | int ret; | ||
406 | u8 val; | ||
407 | |||
408 | deb_info("%s cmd=%d arg=%d\n", __func__, cmd, arg); | ||
409 | switch (cmd) { | ||
410 | case FC_FE_CALLBACK_VHF_ENABLE: | ||
411 | /* set output values */ | ||
412 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
413 | if (ret) | ||
414 | goto err; | ||
415 | |||
416 | if (arg) | ||
417 | val &= 0xbf; /* set GPIO6 low */ | ||
418 | else | ||
419 | val |= 0x40; /* set GPIO6 high */ | ||
420 | |||
421 | |||
422 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
423 | if (ret) | ||
424 | goto err; | ||
425 | break; | ||
426 | default: | ||
427 | ret = -EINVAL; | ||
428 | goto err; | ||
429 | } | ||
430 | return 0; | ||
431 | |||
432 | err: | ||
433 | err("%s: failed=%d\n", __func__, ret); | ||
434 | |||
435 | return ret; | ||
436 | } | ||
437 | |||
438 | |||
439 | static int rtl2832u_fc0013_tuner_callback(struct dvb_usb_device *d, | ||
440 | int cmd, int arg) | ||
441 | { | ||
442 | /* TODO implement*/ | ||
443 | return 0; | ||
444 | } | ||
445 | |||
446 | static int rtl2832u_tuner_callback(struct dvb_usb_device *d, int cmd, int arg) | ||
447 | { | ||
448 | struct rtl28xxu_priv *priv = d->priv; | ||
449 | |||
450 | switch (priv->tuner) { | ||
451 | case TUNER_RTL2832_FC0012: | ||
452 | return rtl2832u_fc0012_tuner_callback(d, cmd, arg); | ||
453 | |||
454 | case TUNER_RTL2832_FC0013: | ||
455 | return rtl2832u_fc0013_tuner_callback(d, cmd, arg); | ||
456 | default: | ||
457 | break; | ||
458 | } | ||
459 | |||
460 | return -ENODEV; | ||
461 | } | ||
462 | |||
463 | static int rtl2832u_frontend_callback(void *adapter_priv, int component, | ||
464 | int cmd, int arg) | ||
465 | { | ||
466 | struct i2c_adapter *adap = adapter_priv; | ||
467 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | ||
468 | |||
469 | switch (component) { | ||
470 | case DVB_FRONTEND_COMPONENT_TUNER: | ||
471 | return rtl2832u_tuner_callback(d, cmd, arg); | ||
472 | default: | ||
473 | break; | ||
474 | } | ||
475 | |||
476 | return -EINVAL; | ||
477 | } | ||
478 | |||
479 | |||
480 | |||
481 | |||
384 | static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) | 482 | static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) |
385 | { | 483 | { |
386 | int ret; | 484 | int ret; |
387 | struct rtl28xxu_priv *priv = adap->dev->priv; | 485 | struct rtl28xxu_priv *priv = adap->dev->priv; |
388 | u8 buf[1]; | 486 | struct rtl2832_config *rtl2832_config; |
487 | |||
488 | u8 buf[2], val; | ||
389 | /* open RTL2832U/RTL2832 I2C gate */ | 489 | /* open RTL2832U/RTL2832 I2C gate */ |
390 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"}; | 490 | struct rtl28xxu_req req_gate_open = {0x0120, 0x0011, 0x0001, "\x18"}; |
391 | /* close RTL2832U/RTL2832 I2C gate */ | 491 | /* close RTL2832U/RTL2832 I2C gate */ |
392 | struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"}; | 492 | struct rtl28xxu_req req_gate_close = {0x0120, 0x0011, 0x0001, "\x10"}; |
493 | /* for FC0012 tuner probe */ | ||
494 | struct rtl28xxu_req req_fc0012 = {0x00c6, CMD_I2C_RD, 1, buf}; | ||
495 | /* for FC0013 tuner probe */ | ||
496 | struct rtl28xxu_req req_fc0013 = {0x00c6, CMD_I2C_RD, 1, buf}; | ||
497 | /* for MT2266 tuner probe */ | ||
498 | struct rtl28xxu_req req_mt2266 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
393 | /* for FC2580 tuner probe */ | 499 | /* for FC2580 tuner probe */ |
394 | struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf}; | 500 | struct rtl28xxu_req req_fc2580 = {0x01ac, CMD_I2C_RD, 1, buf}; |
501 | /* for MT2063 tuner probe */ | ||
502 | struct rtl28xxu_req req_mt2063 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
503 | /* for MAX3543 tuner probe */ | ||
504 | struct rtl28xxu_req req_max3543 = {0x00c0, CMD_I2C_RD, 1, buf}; | ||
505 | /* for TUA9001 tuner probe */ | ||
506 | struct rtl28xxu_req req_tua9001 = {0x7ec0, CMD_I2C_RD, 2, buf}; | ||
507 | /* for MXL5007T tuner probe */ | ||
508 | struct rtl28xxu_req req_mxl5007t = {0xd9c0, CMD_I2C_RD, 1, buf}; | ||
509 | /* for E4000 tuner probe */ | ||
510 | struct rtl28xxu_req req_e4000 = {0x02c8, CMD_I2C_RD, 1, buf}; | ||
511 | /* for TDA18272 tuner probe */ | ||
512 | struct rtl28xxu_req req_tda18272 = {0x00c0, CMD_I2C_RD, 2, buf}; | ||
395 | 513 | ||
396 | deb_info("%s:\n", __func__); | 514 | deb_info("%s:\n", __func__); |
397 | 515 | ||
398 | /* GPIO direction */ | 516 | |
399 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_DIR, 0x0a); | 517 | ret = rtl28xx_rd_reg(adap->dev, SYS_GPIO_DIR, &val); |
400 | if (ret) | 518 | if (ret) |
401 | goto err; | 519 | goto err; |
402 | 520 | ||
403 | /* enable as output GPIO0, GPIO2, GPIO4 */ | 521 | val &= 0xbf; |
404 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_OUT_EN, 0x15); | 522 | |
523 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_DIR, val); | ||
405 | if (ret) | 524 | if (ret) |
406 | goto err; | 525 | goto err; |
407 | 526 | ||
408 | ret = rtl2831_wr_reg(adap->dev, SYS_DEMOD_CTL, 0xe8); | 527 | |
528 | /* enable as output GPIO3 and GPIO6*/ | ||
529 | ret = rtl28xx_rd_reg(adap->dev, SYS_GPIO_OUT_EN, &val); | ||
409 | if (ret) | 530 | if (ret) |
410 | goto err; | 531 | goto err; |
411 | 532 | ||
533 | val |= 0x48; | ||
534 | |||
535 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_OUT_EN, val); | ||
536 | if (ret) | ||
537 | goto err; | ||
538 | |||
539 | |||
540 | |||
412 | /* | 541 | /* |
413 | * Probe used tuner. We need to know used tuner before demod attach | 542 | * Probe used tuner. We need to know used tuner before demod attach |
414 | * since there is some demod params needed to set according to tuner. | 543 | * since there is some demod params needed to set according to tuner. |
@@ -419,25 +548,108 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap) | |||
419 | if (ret) | 548 | if (ret) |
420 | goto err; | 549 | goto err; |
421 | 550 | ||
551 | priv->tuner = TUNER_NONE; | ||
552 | |||
553 | /* check FC0012 ID register; reg=00 val=a1 */ | ||
554 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc0012); | ||
555 | if (ret == 0 && buf[0] == 0xa1) { | ||
556 | priv->tuner = TUNER_RTL2832_FC0012; | ||
557 | rtl2832_config = &rtl28xxu_rtl2832_fc0012_config; | ||
558 | info("%s: FC0012 tuner found", __func__); | ||
559 | goto found; | ||
560 | } | ||
561 | |||
562 | /* check FC0013 ID register; reg=00 val=a3 */ | ||
563 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc0013); | ||
564 | if (ret == 0 && buf[0] == 0xa3) { | ||
565 | priv->tuner = TUNER_RTL2832_FC0013; | ||
566 | rtl2832_config = &rtl28xxu_rtl2832_fc0013_config; | ||
567 | info("%s: FC0013 tuner found", __func__); | ||
568 | goto found; | ||
569 | } | ||
570 | |||
571 | /* check MT2266 ID register; reg=00 val=85 */ | ||
572 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mt2266); | ||
573 | if (ret == 0 && buf[0] == 0x85) { | ||
574 | priv->tuner = TUNER_RTL2832_MT2266; | ||
575 | /* TODO implement tuner */ | ||
576 | info("%s: MT2266 tuner found", __func__); | ||
577 | goto unsupported; | ||
578 | } | ||
579 | |||
422 | /* check FC2580 ID register; reg=01 val=56 */ | 580 | /* check FC2580 ID register; reg=01 val=56 */ |
423 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc2580); | 581 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_fc2580); |
424 | if (ret == 0 && buf[0] == 0x56) { | 582 | if (ret == 0 && buf[0] == 0x56) { |
425 | priv->tuner = TUNER_RTL2832_FC2580; | 583 | priv->tuner = TUNER_RTL2832_FC2580; |
426 | deb_info("%s: FC2580\n", __func__); | 584 | /* TODO implement tuner */ |
427 | goto found; | 585 | info("%s: FC2580 tuner found", __func__); |
428 | } else { | 586 | goto unsupported; |
429 | deb_info("%s: FC2580 probe failed=%d - %02x\n", | ||
430 | __func__, ret, buf[0]); | ||
431 | } | 587 | } |
432 | 588 | ||
589 | /* check MT2063 ID register; reg=00 val=9e || 9c */ | ||
590 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mt2063); | ||
591 | if (ret == 0 && (buf[0] == 0x9e || buf[0] == 0x9c)) { | ||
592 | priv->tuner = TUNER_RTL2832_MT2063; | ||
593 | /* TODO implement tuner */ | ||
594 | info("%s: MT2063 tuner found", __func__); | ||
595 | goto unsupported; | ||
596 | } | ||
597 | |||
598 | /* check MAX3543 ID register; reg=00 val=38 */ | ||
599 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_max3543); | ||
600 | if (ret == 0 && buf[0] == 0x38) { | ||
601 | priv->tuner = TUNER_RTL2832_MAX3543; | ||
602 | /* TODO implement tuner */ | ||
603 | info("%s: MAX3534 tuner found", __func__); | ||
604 | goto unsupported; | ||
605 | } | ||
606 | |||
607 | /* check TUA9001 ID register; reg=7e val=2328 */ | ||
608 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_tua9001); | ||
609 | if (ret == 0 && buf[0] == 0x23 && buf[1] == 0x28) { | ||
610 | priv->tuner = TUNER_RTL2832_TUA9001; | ||
611 | /* TODO implement tuner */ | ||
612 | info("%s: TUA9001 tuner found", __func__); | ||
613 | goto unsupported; | ||
614 | } | ||
615 | |||
616 | /* check MXL5007R ID register; reg=d9 val=14 */ | ||
617 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_mxl5007t); | ||
618 | if (ret == 0 && buf[0] == 0x14) { | ||
619 | priv->tuner = TUNER_RTL2832_MXL5007T; | ||
620 | /* TODO implement tuner */ | ||
621 | info("%s: MXL5007T tuner found", __func__); | ||
622 | goto unsupported; | ||
623 | } | ||
624 | |||
625 | /* check E4000 ID register; reg=02 val=40 */ | ||
626 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_e4000); | ||
627 | if (ret == 0 && buf[0] == 0x40) { | ||
628 | priv->tuner = TUNER_RTL2832_E4000; | ||
629 | /* TODO implement tuner */ | ||
630 | info("%s: E4000 tuner found", __func__); | ||
631 | goto unsupported; | ||
632 | } | ||
633 | |||
634 | /* check TDA18272 ID register; reg=00 val=c760 */ | ||
635 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_tda18272); | ||
636 | if (ret == 0 && (buf[0] == 0xc7 || buf[1] == 0x60)) { | ||
637 | priv->tuner = TUNER_RTL2832_TDA18272; | ||
638 | /* TODO implement tuner */ | ||
639 | info("%s: TDA18272 tuner found", __func__); | ||
640 | goto unsupported; | ||
641 | } | ||
642 | |||
643 | unsupported: | ||
433 | /* close demod I2C gate */ | 644 | /* close demod I2C gate */ |
434 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_gate_close); | 645 | ret = rtl28xxu_ctrl_msg(adap->dev, &req_gate_close); |
435 | if (ret) | 646 | if (ret) |
436 | goto err; | 647 | goto err; |
437 | 648 | ||
438 | /* tuner not found */ | 649 | /* tuner not found */ |
650 | deb_info("No compatible tuner found"); | ||
439 | ret = -ENODEV; | 651 | ret = -ENODEV; |
440 | goto err; | 652 | return ret; |
441 | 653 | ||
442 | found: | 654 | found: |
443 | /* close demod I2C gate */ | 655 | /* close demod I2C gate */ |
@@ -446,9 +658,18 @@ found: | |||
446 | goto err; | 658 | goto err; |
447 | 659 | ||
448 | /* attach demodulator */ | 660 | /* attach demodulator */ |
449 | /* TODO: */ | 661 | adap->fe_adap[0].fe = dvb_attach(rtl2832_attach, rtl2832_config, |
662 | &adap->dev->i2c_adap); | ||
663 | if (adap->fe_adap[0].fe == NULL) { | ||
664 | ret = -ENODEV; | ||
665 | goto err; | ||
666 | } | ||
667 | |||
668 | /* set fe callbacks */ | ||
669 | adap->fe_adap[0].fe->callback = rtl2832u_frontend_callback; | ||
450 | 670 | ||
451 | return ret; | 671 | return ret; |
672 | |||
452 | err: | 673 | err: |
453 | deb_info("%s: failed=%d\n", __func__, ret); | 674 | deb_info("%s: failed=%d\n", __func__, ret); |
454 | return ret; | 675 | return ret; |
@@ -531,10 +752,24 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
531 | deb_info("%s:\n", __func__); | 752 | deb_info("%s:\n", __func__); |
532 | 753 | ||
533 | switch (priv->tuner) { | 754 | switch (priv->tuner) { |
534 | case TUNER_RTL2832_FC2580: | 755 | case TUNER_RTL2832_FC0012: |
535 | /* TODO: */ | 756 | fe = dvb_attach(fc0012_attach, adap->fe_adap[0].fe, |
536 | fe = NULL; | 757 | &adap->dev->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); |
758 | |||
759 | /* since fc0012 includs reading the signal strength delegate | ||
760 | * that to the tuner driver */ | ||
761 | adap->fe_adap[0].fe->ops.read_signal_strength = adap->fe_adap[0]. | ||
762 | fe->ops.tuner_ops.get_rf_strength; | ||
763 | return 0; | ||
537 | break; | 764 | break; |
765 | case TUNER_RTL2832_FC0013: | ||
766 | fe = dvb_attach(fc0013_attach, adap->fe_adap[0].fe, | ||
767 | &adap->dev->i2c_adap, 0xc6>>1, 0, FC_XTAL_28_8_MHZ); | ||
768 | |||
769 | /* fc0013 also supports signal strength reading */ | ||
770 | adap->fe_adap[0].fe->ops.read_signal_strength = adap->fe_adap[0] | ||
771 | .fe->ops.tuner_ops.get_rf_strength; | ||
772 | return 0; | ||
538 | default: | 773 | default: |
539 | fe = NULL; | 774 | fe = NULL; |
540 | err("unknown tuner=%d", priv->tuner); | 775 | err("unknown tuner=%d", priv->tuner); |
@@ -551,14 +786,14 @@ err: | |||
551 | return ret; | 786 | return ret; |
552 | } | 787 | } |
553 | 788 | ||
554 | static int rtl28xxu_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) | 789 | static int rtl2831u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) |
555 | { | 790 | { |
556 | int ret; | 791 | int ret; |
557 | u8 buf[2], gpio; | 792 | u8 buf[2], gpio; |
558 | 793 | ||
559 | deb_info("%s: onoff=%d\n", __func__, onoff); | 794 | deb_info("%s: onoff=%d\n", __func__, onoff); |
560 | 795 | ||
561 | ret = rtl2831_rd_reg(adap->dev, SYS_GPIO_OUT_VAL, &gpio); | 796 | ret = rtl28xx_rd_reg(adap->dev, SYS_GPIO_OUT_VAL, &gpio); |
562 | if (ret) | 797 | if (ret) |
563 | goto err; | 798 | goto err; |
564 | 799 | ||
@@ -572,11 +807,37 @@ static int rtl28xxu_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) | |||
572 | gpio &= (~0x04); /* LED off */ | 807 | gpio &= (~0x04); /* LED off */ |
573 | } | 808 | } |
574 | 809 | ||
575 | ret = rtl2831_wr_reg(adap->dev, SYS_GPIO_OUT_VAL, gpio); | 810 | ret = rtl28xx_wr_reg(adap->dev, SYS_GPIO_OUT_VAL, gpio); |
576 | if (ret) | 811 | if (ret) |
577 | goto err; | 812 | goto err; |
578 | 813 | ||
579 | ret = rtl2831_wr_regs(adap->dev, USB_EPA_CTL, buf, 2); | 814 | ret = rtl28xx_wr_regs(adap->dev, USB_EPA_CTL, buf, 2); |
815 | if (ret) | ||
816 | goto err; | ||
817 | |||
818 | return ret; | ||
819 | err: | ||
820 | deb_info("%s: failed=%d\n", __func__, ret); | ||
821 | return ret; | ||
822 | } | ||
823 | |||
824 | static int rtl2832u_streaming_ctrl(struct dvb_usb_adapter *adap , int onoff) | ||
825 | { | ||
826 | int ret; | ||
827 | u8 buf[2]; | ||
828 | |||
829 | deb_info("%s: onoff=%d\n", __func__, onoff); | ||
830 | |||
831 | |||
832 | if (onoff) { | ||
833 | buf[0] = 0x00; | ||
834 | buf[1] = 0x00; | ||
835 | } else { | ||
836 | buf[0] = 0x10; /* stall EPA */ | ||
837 | buf[1] = 0x02; /* reset EPA */ | ||
838 | } | ||
839 | |||
840 | ret = rtl28xx_wr_regs(adap->dev, USB_EPA_CTL, buf, 2); | ||
580 | if (ret) | 841 | if (ret) |
581 | goto err; | 842 | goto err; |
582 | 843 | ||
@@ -586,7 +847,7 @@ err: | |||
586 | return ret; | 847 | return ret; |
587 | } | 848 | } |
588 | 849 | ||
589 | static int rtl28xxu_power_ctrl(struct dvb_usb_device *d, int onoff) | 850 | static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) |
590 | { | 851 | { |
591 | int ret; | 852 | int ret; |
592 | u8 gpio, sys0; | 853 | u8 gpio, sys0; |
@@ -594,12 +855,12 @@ static int rtl28xxu_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
594 | deb_info("%s: onoff=%d\n", __func__, onoff); | 855 | deb_info("%s: onoff=%d\n", __func__, onoff); |
595 | 856 | ||
596 | /* demod adc */ | 857 | /* demod adc */ |
597 | ret = rtl2831_rd_reg(d, SYS_SYS0, &sys0); | 858 | ret = rtl28xx_rd_reg(d, SYS_SYS0, &sys0); |
598 | if (ret) | 859 | if (ret) |
599 | goto err; | 860 | goto err; |
600 | 861 | ||
601 | /* tuner power, read GPIOs */ | 862 | /* tuner power, read GPIOs */ |
602 | ret = rtl2831_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio); | 863 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &gpio); |
603 | if (ret) | 864 | if (ret) |
604 | goto err; | 865 | goto err; |
605 | 866 | ||
@@ -619,12 +880,12 @@ static int rtl28xxu_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
619 | deb_info("%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__, sys0, gpio); | 880 | deb_info("%s: WR SYS0=%02x GPIO_OUT_VAL=%02x\n", __func__, sys0, gpio); |
620 | 881 | ||
621 | /* demod adc */ | 882 | /* demod adc */ |
622 | ret = rtl2831_wr_reg(d, SYS_SYS0, sys0); | 883 | ret = rtl28xx_wr_reg(d, SYS_SYS0, sys0); |
623 | if (ret) | 884 | if (ret) |
624 | goto err; | 885 | goto err; |
625 | 886 | ||
626 | /* tuner power, write GPIOs */ | 887 | /* tuner power, write GPIOs */ |
627 | ret = rtl2831_wr_reg(d, SYS_GPIO_OUT_VAL, gpio); | 888 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, gpio); |
628 | if (ret) | 889 | if (ret) |
629 | goto err; | 890 | goto err; |
630 | 891 | ||
@@ -634,6 +895,128 @@ err: | |||
634 | return ret; | 895 | return ret; |
635 | } | 896 | } |
636 | 897 | ||
898 | static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) | ||
899 | { | ||
900 | int ret; | ||
901 | u8 val; | ||
902 | |||
903 | deb_info("%s: onoff=%d\n", __func__, onoff); | ||
904 | |||
905 | if (onoff) { | ||
906 | /* set output values */ | ||
907 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
908 | if (ret) | ||
909 | goto err; | ||
910 | |||
911 | val |= 0x08; | ||
912 | val &= 0xef; | ||
913 | |||
914 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
915 | if (ret) | ||
916 | goto err; | ||
917 | |||
918 | /* demod_ctl_1 */ | ||
919 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val); | ||
920 | if (ret) | ||
921 | goto err; | ||
922 | |||
923 | val &= 0xef; | ||
924 | |||
925 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val); | ||
926 | if (ret) | ||
927 | goto err; | ||
928 | |||
929 | /* demod control */ | ||
930 | /* PLL enable */ | ||
931 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
932 | if (ret) | ||
933 | goto err; | ||
934 | |||
935 | /* bit 7 to 1 */ | ||
936 | val |= 0x80; | ||
937 | |||
938 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
939 | if (ret) | ||
940 | goto err; | ||
941 | |||
942 | /* demod HW reset */ | ||
943 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
944 | if (ret) | ||
945 | goto err; | ||
946 | /* bit 5 to 0 */ | ||
947 | val &= 0xdf; | ||
948 | |||
949 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
950 | if (ret) | ||
951 | goto err; | ||
952 | |||
953 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
954 | if (ret) | ||
955 | goto err; | ||
956 | |||
957 | val |= 0x20; | ||
958 | |||
959 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
960 | if (ret) | ||
961 | goto err; | ||
962 | |||
963 | mdelay(5); | ||
964 | |||
965 | /*enable ADC_Q and ADC_I */ | ||
966 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
967 | if (ret) | ||
968 | goto err; | ||
969 | |||
970 | val |= 0x48; | ||
971 | |||
972 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
973 | if (ret) | ||
974 | goto err; | ||
975 | |||
976 | |||
977 | } else { | ||
978 | /* demod_ctl_1 */ | ||
979 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val); | ||
980 | if (ret) | ||
981 | goto err; | ||
982 | |||
983 | val |= 0x0c; | ||
984 | |||
985 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val); | ||
986 | if (ret) | ||
987 | goto err; | ||
988 | |||
989 | /* set output values */ | ||
990 | ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); | ||
991 | if (ret) | ||
992 | goto err; | ||
993 | |||
994 | val |= 0x10; | ||
995 | |||
996 | ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val); | ||
997 | if (ret) | ||
998 | goto err; | ||
999 | |||
1000 | /* demod control */ | ||
1001 | ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); | ||
1002 | if (ret) | ||
1003 | goto err; | ||
1004 | |||
1005 | val &= 0x37; | ||
1006 | |||
1007 | ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val); | ||
1008 | if (ret) | ||
1009 | goto err; | ||
1010 | |||
1011 | } | ||
1012 | |||
1013 | return ret; | ||
1014 | err: | ||
1015 | deb_info("%s: failed=%d\n", __func__, ret); | ||
1016 | return ret; | ||
1017 | } | ||
1018 | |||
1019 | |||
637 | static int rtl2831u_rc_query(struct dvb_usb_device *d) | 1020 | static int rtl2831u_rc_query(struct dvb_usb_device *d) |
638 | { | 1021 | { |
639 | int ret, i; | 1022 | int ret, i; |
@@ -660,7 +1043,7 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) | |||
660 | /* init remote controller */ | 1043 | /* init remote controller */ |
661 | if (!priv->rc_active) { | 1044 | if (!priv->rc_active) { |
662 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { | 1045 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
663 | ret = rtl2831_wr_reg(d, rc_nec_tab[i].reg, | 1046 | ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg, |
664 | rc_nec_tab[i].val); | 1047 | rc_nec_tab[i].val); |
665 | if (ret) | 1048 | if (ret) |
666 | goto err; | 1049 | goto err; |
@@ -690,12 +1073,12 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) | |||
690 | 1073 | ||
691 | rc_keydown(d->rc_dev, rc_code, 0); | 1074 | rc_keydown(d->rc_dev, rc_code, 0); |
692 | 1075 | ||
693 | ret = rtl2831_wr_reg(d, SYS_IRRC_SR, 1); | 1076 | ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); |
694 | if (ret) | 1077 | if (ret) |
695 | goto err; | 1078 | goto err; |
696 | 1079 | ||
697 | /* repeated intentionally to avoid extra keypress */ | 1080 | /* repeated intentionally to avoid extra keypress */ |
698 | ret = rtl2831_wr_reg(d, SYS_IRRC_SR, 1); | 1081 | ret = rtl28xx_wr_reg(d, SYS_IRRC_SR, 1); |
699 | if (ret) | 1082 | if (ret) |
700 | goto err; | 1083 | goto err; |
701 | } | 1084 | } |
@@ -732,7 +1115,7 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) | |||
732 | /* init remote controller */ | 1115 | /* init remote controller */ |
733 | if (!priv->rc_active) { | 1116 | if (!priv->rc_active) { |
734 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { | 1117 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
735 | ret = rtl2831_wr_reg(d, rc_nec_tab[i].reg, | 1118 | ret = rtl28xx_wr_reg(d, rc_nec_tab[i].reg, |
736 | rc_nec_tab[i].val); | 1119 | rc_nec_tab[i].val); |
737 | if (ret) | 1120 | if (ret) |
738 | goto err; | 1121 | goto err; |
@@ -740,14 +1123,14 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) | |||
740 | priv->rc_active = true; | 1123 | priv->rc_active = true; |
741 | } | 1124 | } |
742 | 1125 | ||
743 | ret = rtl2831_rd_reg(d, IR_RX_IF, &buf[0]); | 1126 | ret = rtl28xx_rd_reg(d, IR_RX_IF, &buf[0]); |
744 | if (ret) | 1127 | if (ret) |
745 | goto err; | 1128 | goto err; |
746 | 1129 | ||
747 | if (buf[0] != 0x83) | 1130 | if (buf[0] != 0x83) |
748 | goto exit; | 1131 | goto exit; |
749 | 1132 | ||
750 | ret = rtl2831_rd_reg(d, IR_RX_BC, &buf[0]); | 1133 | ret = rtl28xx_rd_reg(d, IR_RX_BC, &buf[0]); |
751 | if (ret) | 1134 | if (ret) |
752 | goto err; | 1135 | goto err; |
753 | 1136 | ||
@@ -756,9 +1139,9 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) | |||
756 | 1139 | ||
757 | /* TODO: pass raw IR to Kernel IR decoder */ | 1140 | /* TODO: pass raw IR to Kernel IR decoder */ |
758 | 1141 | ||
759 | ret = rtl2831_wr_reg(d, IR_RX_IF, 0x03); | 1142 | ret = rtl28xx_wr_reg(d, IR_RX_IF, 0x03); |
760 | ret = rtl2831_wr_reg(d, IR_RX_BUF_CTRL, 0x80); | 1143 | ret = rtl28xx_wr_reg(d, IR_RX_BUF_CTRL, 0x80); |
761 | ret = rtl2831_wr_reg(d, IR_RX_CTRL, 0x80); | 1144 | ret = rtl28xx_wr_reg(d, IR_RX_CTRL, 0x80); |
762 | 1145 | ||
763 | exit: | 1146 | exit: |
764 | return ret; | 1147 | return ret; |
@@ -771,6 +1154,9 @@ enum rtl28xxu_usb_table_entry { | |||
771 | RTL2831U_0BDA_2831, | 1154 | RTL2831U_0BDA_2831, |
772 | RTL2831U_14AA_0160, | 1155 | RTL2831U_14AA_0160, |
773 | RTL2831U_14AA_0161, | 1156 | RTL2831U_14AA_0161, |
1157 | RTL2832U_0CCD_00A9, | ||
1158 | RTL2832U_1F4D_B803, | ||
1159 | RTL2832U_0CCD_00B3, | ||
774 | }; | 1160 | }; |
775 | 1161 | ||
776 | static struct usb_device_id rtl28xxu_table[] = { | 1162 | static struct usb_device_id rtl28xxu_table[] = { |
@@ -783,6 +1169,12 @@ static struct usb_device_id rtl28xxu_table[] = { | |||
783 | USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2)}, | 1169 | USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT_2)}, |
784 | 1170 | ||
785 | /* RTL2832U */ | 1171 | /* RTL2832U */ |
1172 | [RTL2832U_0CCD_00A9] = { | ||
1173 | USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK_BLACK_REV1)}, | ||
1174 | [RTL2832U_1F4D_B803] = { | ||
1175 | USB_DEVICE(USB_VID_GTEK, USB_PID_DELOCK_USB2_DVBT)}, | ||
1176 | [RTL2832U_0CCD_00B3] = { | ||
1177 | USB_DEVICE(USB_VID_TERRATEC, USB_PID_NOXON_DAB_STICK)}, | ||
786 | {} /* terminating entry */ | 1178 | {} /* terminating entry */ |
787 | }; | 1179 | }; |
788 | 1180 | ||
@@ -805,7 +1197,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
805 | { | 1197 | { |
806 | .frontend_attach = rtl2831u_frontend_attach, | 1198 | .frontend_attach = rtl2831u_frontend_attach, |
807 | .tuner_attach = rtl2831u_tuner_attach, | 1199 | .tuner_attach = rtl2831u_tuner_attach, |
808 | .streaming_ctrl = rtl28xxu_streaming_ctrl, | 1200 | .streaming_ctrl = rtl2831u_streaming_ctrl, |
809 | .stream = { | 1201 | .stream = { |
810 | .type = USB_BULK, | 1202 | .type = USB_BULK, |
811 | .count = 6, | 1203 | .count = 6, |
@@ -821,7 +1213,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
821 | } | 1213 | } |
822 | }, | 1214 | }, |
823 | 1215 | ||
824 | .power_ctrl = rtl28xxu_power_ctrl, | 1216 | .power_ctrl = rtl2831u_power_ctrl, |
825 | 1217 | ||
826 | .rc.core = { | 1218 | .rc.core = { |
827 | .protocol = RC_TYPE_NEC, | 1219 | .protocol = RC_TYPE_NEC, |
@@ -867,7 +1259,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
867 | { | 1259 | { |
868 | .frontend_attach = rtl2832u_frontend_attach, | 1260 | .frontend_attach = rtl2832u_frontend_attach, |
869 | .tuner_attach = rtl2832u_tuner_attach, | 1261 | .tuner_attach = rtl2832u_tuner_attach, |
870 | .streaming_ctrl = rtl28xxu_streaming_ctrl, | 1262 | .streaming_ctrl = rtl2832u_streaming_ctrl, |
871 | .stream = { | 1263 | .stream = { |
872 | .type = USB_BULK, | 1264 | .type = USB_BULK, |
873 | .count = 6, | 1265 | .count = 6, |
@@ -883,7 +1275,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
883 | } | 1275 | } |
884 | }, | 1276 | }, |
885 | 1277 | ||
886 | .power_ctrl = rtl28xxu_power_ctrl, | 1278 | .power_ctrl = rtl2832u_power_ctrl, |
887 | 1279 | ||
888 | .rc.core = { | 1280 | .rc.core = { |
889 | .protocol = RC_TYPE_NEC, | 1281 | .protocol = RC_TYPE_NEC, |
@@ -896,10 +1288,25 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
896 | 1288 | ||
897 | .i2c_algo = &rtl28xxu_i2c_algo, | 1289 | .i2c_algo = &rtl28xxu_i2c_algo, |
898 | 1290 | ||
899 | .num_device_descs = 0, /* disabled as no support for RTL2832 */ | 1291 | .num_device_descs = 3, |
900 | .devices = { | 1292 | .devices = { |
901 | { | 1293 | { |
902 | .name = "Realtek RTL2832U reference design", | 1294 | .name = "Terratec Cinergy T Stick Black", |
1295 | .warm_ids = { | ||
1296 | &rtl28xxu_table[RTL2832U_0CCD_00A9], | ||
1297 | }, | ||
1298 | }, | ||
1299 | { | ||
1300 | .name = "G-Tek Electronics Group Lifeview LV5TDLX DVB-T", | ||
1301 | .warm_ids = { | ||
1302 | &rtl28xxu_table[RTL2832U_1F4D_B803], | ||
1303 | }, | ||
1304 | }, | ||
1305 | { | ||
1306 | .name = "NOXON DAB/DAB+ USB dongle", | ||
1307 | .warm_ids = { | ||
1308 | &rtl28xxu_table[RTL2832U_0CCD_00B3], | ||
1309 | }, | ||
903 | }, | 1310 | }, |
904 | } | 1311 | } |
905 | }, | 1312 | }, |
@@ -910,6 +1317,7 @@ static int rtl28xxu_probe(struct usb_interface *intf, | |||
910 | const struct usb_device_id *id) | 1317 | const struct usb_device_id *id) |
911 | { | 1318 | { |
912 | int ret, i; | 1319 | int ret, i; |
1320 | u8 val; | ||
913 | int properties_count = ARRAY_SIZE(rtl28xxu_properties); | 1321 | int properties_count = ARRAY_SIZE(rtl28xxu_properties); |
914 | struct dvb_usb_device *d; | 1322 | struct dvb_usb_device *d; |
915 | struct usb_device *udev; | 1323 | struct usb_device *udev; |
@@ -954,16 +1362,25 @@ static int rtl28xxu_probe(struct usb_interface *intf, | |||
954 | if (ret) | 1362 | if (ret) |
955 | goto err; | 1363 | goto err; |
956 | 1364 | ||
1365 | |||
957 | /* init USB endpoints */ | 1366 | /* init USB endpoints */ |
958 | ret = rtl2831_wr_reg(d, USB_SYSCTL_0, 0x09); | 1367 | ret = rtl28xx_rd_reg(d, USB_SYSCTL_0, &val); |
1368 | if (ret) | ||
1369 | goto err; | ||
1370 | |||
1371 | /* enable DMA and Full Packet Mode*/ | ||
1372 | val |= 0x09; | ||
1373 | ret = rtl28xx_wr_reg(d, USB_SYSCTL_0, val); | ||
959 | if (ret) | 1374 | if (ret) |
960 | goto err; | 1375 | goto err; |
961 | 1376 | ||
962 | ret = rtl2831_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); | 1377 | /* set EPA maximum packet size to 0x0200 */ |
1378 | ret = rtl28xx_wr_regs(d, USB_EPA_MAXPKT, "\x00\x02\x00\x00", 4); | ||
963 | if (ret) | 1379 | if (ret) |
964 | goto err; | 1380 | goto err; |
965 | 1381 | ||
966 | ret = rtl2831_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); | 1382 | /* change EPA FIFO length */ |
1383 | ret = rtl28xx_wr_regs(d, USB_EPA_FIFO_CFG, "\x14\x00\x00\x00", 4); | ||
967 | if (ret) | 1384 | if (ret) |
968 | goto err; | 1385 | goto err; |
969 | 1386 | ||
@@ -1007,4 +1424,5 @@ module_exit(rtl28xxu_module_exit); | |||
1007 | 1424 | ||
1008 | MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver"); | 1425 | MODULE_DESCRIPTION("Realtek RTL28xxU DVB USB driver"); |
1009 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | 1426 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
1427 | MODULE_AUTHOR("Thomas Mair <thomas.mair86@googlemail.com>"); | ||
1010 | MODULE_LICENSE("GPL"); | 1428 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index b98ebb264e29..a08c2152d0ee 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config DVB_FE_CUSTOMISE | 1 | config DVB_FE_CUSTOMISE |
2 | bool "Customise the frontend modules to build" | 2 | bool "Customise the frontend modules to build" |
3 | depends on DVB_CORE | 3 | depends on DVB_CORE |
4 | depends on EXPERT | ||
4 | default y if EXPERT | 5 | default y if EXPERT |
5 | help | 6 | help |
6 | This allows the user to select/deselect frontend drivers for their | 7 | This allows the user to select/deselect frontend drivers for their |
@@ -432,6 +433,13 @@ config DVB_RTL2830 | |||
432 | help | 433 | help |
433 | Say Y when you want to support this frontend. | 434 | Say Y when you want to support this frontend. |
434 | 435 | ||
436 | config DVB_RTL2832 | ||
437 | tristate "Realtek RTL2832 DVB-T" | ||
438 | depends on DVB_CORE && I2C | ||
439 | default m if DVB_FE_CUSTOMISE | ||
440 | help | ||
441 | Say Y when you want to support this frontend. | ||
442 | |||
435 | comment "DVB-C (cable) frontends" | 443 | comment "DVB-C (cable) frontends" |
436 | depends on DVB_CORE | 444 | depends on DVB_CORE |
437 | 445 | ||
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index cd1ac2fd5774..185bb8b51952 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile | |||
@@ -99,6 +99,7 @@ obj-$(CONFIG_DVB_IT913X_FE) += it913x-fe.o | |||
99 | obj-$(CONFIG_DVB_A8293) += a8293.o | 99 | obj-$(CONFIG_DVB_A8293) += a8293.o |
100 | obj-$(CONFIG_DVB_TDA10071) += tda10071.o | 100 | obj-$(CONFIG_DVB_TDA10071) += tda10071.o |
101 | obj-$(CONFIG_DVB_RTL2830) += rtl2830.o | 101 | obj-$(CONFIG_DVB_RTL2830) += rtl2830.o |
102 | obj-$(CONFIG_DVB_RTL2832) += rtl2832.o | ||
102 | obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o | 103 | obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o |
103 | obj-$(CONFIG_DVB_AF9033) += af9033.o | 104 | obj-$(CONFIG_DVB_AF9033) += af9033.o |
104 | 105 | ||
diff --git a/drivers/media/dvb/frontends/a8293.c b/drivers/media/dvb/frontends/a8293.c index bb56497e940a..cff44a389b40 100644 --- a/drivers/media/dvb/frontends/a8293.c +++ b/drivers/media/dvb/frontends/a8293.c | |||
@@ -21,24 +21,6 @@ | |||
21 | #include "dvb_frontend.h" | 21 | #include "dvb_frontend.h" |
22 | #include "a8293.h" | 22 | #include "a8293.h" |
23 | 23 | ||
24 | static int debug; | ||
25 | module_param(debug, int, 0644); | ||
26 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | ||
27 | |||
28 | #define LOG_PREFIX "a8293" | ||
29 | |||
30 | #undef dbg | ||
31 | #define dbg(f, arg...) \ | ||
32 | if (debug) \ | ||
33 | printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
34 | #undef err | ||
35 | #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) | ||
36 | #undef info | ||
37 | #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
38 | #undef warn | ||
39 | #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg) | ||
40 | |||
41 | |||
42 | struct a8293_priv { | 24 | struct a8293_priv { |
43 | struct i2c_adapter *i2c; | 25 | struct i2c_adapter *i2c; |
44 | const struct a8293_config *cfg; | 26 | const struct a8293_config *cfg; |
@@ -65,7 +47,8 @@ static int a8293_i2c(struct a8293_priv *priv, u8 *val, int len, bool rd) | |||
65 | if (ret == 1) { | 47 | if (ret == 1) { |
66 | ret = 0; | 48 | ret = 0; |
67 | } else { | 49 | } else { |
68 | warn("i2c failed=%d rd=%d", ret, rd); | 50 | dev_warn(&priv->i2c->dev, "%s: i2c failed=%d rd=%d\n", |
51 | KBUILD_MODNAME, ret, rd); | ||
69 | ret = -EREMOTEIO; | 52 | ret = -EREMOTEIO; |
70 | } | 53 | } |
71 | 54 | ||
@@ -88,7 +71,8 @@ static int a8293_set_voltage(struct dvb_frontend *fe, | |||
88 | struct a8293_priv *priv = fe->sec_priv; | 71 | struct a8293_priv *priv = fe->sec_priv; |
89 | int ret; | 72 | int ret; |
90 | 73 | ||
91 | dbg("%s: fe_sec_voltage=%d", __func__, fe_sec_voltage); | 74 | dev_dbg(&priv->i2c->dev, "%s: fe_sec_voltage=%d\n", __func__, |
75 | fe_sec_voltage); | ||
92 | 76 | ||
93 | switch (fe_sec_voltage) { | 77 | switch (fe_sec_voltage) { |
94 | case SEC_VOLTAGE_OFF: | 78 | case SEC_VOLTAGE_OFF: |
@@ -114,14 +98,12 @@ static int a8293_set_voltage(struct dvb_frontend *fe, | |||
114 | 98 | ||
115 | return ret; | 99 | return ret; |
116 | err: | 100 | err: |
117 | dbg("%s: failed=%d", __func__, ret); | 101 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
118 | return ret; | 102 | return ret; |
119 | } | 103 | } |
120 | 104 | ||
121 | static void a8293_release_sec(struct dvb_frontend *fe) | 105 | static void a8293_release_sec(struct dvb_frontend *fe) |
122 | { | 106 | { |
123 | dbg("%s:", __func__); | ||
124 | |||
125 | a8293_set_voltage(fe, SEC_VOLTAGE_OFF); | 107 | a8293_set_voltage(fe, SEC_VOLTAGE_OFF); |
126 | 108 | ||
127 | kfree(fe->sec_priv); | 109 | kfree(fe->sec_priv); |
@@ -154,7 +136,7 @@ struct dvb_frontend *a8293_attach(struct dvb_frontend *fe, | |||
154 | 136 | ||
155 | /* ENB=0 */ | 137 | /* ENB=0 */ |
156 | priv->reg[0] = 0x10; | 138 | priv->reg[0] = 0x10; |
157 | ret = a8293_wr(priv, &priv->reg[1], 1); | 139 | ret = a8293_wr(priv, &priv->reg[0], 1); |
158 | if (ret) | 140 | if (ret) |
159 | goto err; | 141 | goto err; |
160 | 142 | ||
@@ -164,16 +146,17 @@ struct dvb_frontend *a8293_attach(struct dvb_frontend *fe, | |||
164 | if (ret) | 146 | if (ret) |
165 | goto err; | 147 | goto err; |
166 | 148 | ||
167 | info("Allegro A8293 SEC attached."); | ||
168 | |||
169 | fe->ops.release_sec = a8293_release_sec; | 149 | fe->ops.release_sec = a8293_release_sec; |
170 | 150 | ||
171 | /* override frontend ops */ | 151 | /* override frontend ops */ |
172 | fe->ops.set_voltage = a8293_set_voltage; | 152 | fe->ops.set_voltage = a8293_set_voltage; |
173 | 153 | ||
154 | dev_info(&priv->i2c->dev, "%s: Allegro A8293 SEC attached\n", | ||
155 | KBUILD_MODNAME); | ||
156 | |||
174 | return fe; | 157 | return fe; |
175 | err: | 158 | err: |
176 | dbg("%s: failed=%d", __func__, ret); | 159 | dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); |
177 | kfree(priv); | 160 | kfree(priv); |
178 | return NULL; | 161 | return NULL; |
179 | } | 162 | } |
diff --git a/drivers/media/dvb/frontends/drxk.h b/drivers/media/dvb/frontends/drxk.h index 9d64e4fea066..d615d7d055a2 100644 --- a/drivers/media/dvb/frontends/drxk.h +++ b/drivers/media/dvb/frontends/drxk.h | |||
@@ -20,6 +20,14 @@ | |||
20 | * means that 1=DVBC, 0 = DVBT. Zero means the opposite. | 20 | * means that 1=DVBC, 0 = DVBT. Zero means the opposite. |
21 | * @mpeg_out_clk_strength: DRXK Mpeg output clock drive strength. | 21 | * @mpeg_out_clk_strength: DRXK Mpeg output clock drive strength. |
22 | * @microcode_name: Name of the firmware file with the microcode | 22 | * @microcode_name: Name of the firmware file with the microcode |
23 | * @qam_demod_parameter_count: The number of parameters used for the command | ||
24 | * to set the demodulator parameters. All | ||
25 | * firmwares are using the 2-parameter commmand. | ||
26 | * An exception is the "drxk_a3.mc" firmware, | ||
27 | * which uses the 4-parameter command. | ||
28 | * A value of 0 (default) or lower indicates that | ||
29 | * the correct number of parameters will be | ||
30 | * automatically detected. | ||
23 | * | 31 | * |
24 | * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is | 32 | * On the *_gpio vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is |
25 | * UIO-3. | 33 | * UIO-3. |
@@ -38,7 +46,8 @@ struct drxk_config { | |||
38 | u8 mpeg_out_clk_strength; | 46 | u8 mpeg_out_clk_strength; |
39 | int chunk_size; | 47 | int chunk_size; |
40 | 48 | ||
41 | const char *microcode_name; | 49 | const char *microcode_name; |
50 | int qam_demod_parameter_count; | ||
42 | }; | 51 | }; |
43 | 52 | ||
44 | #if defined(CONFIG_DVB_DRXK) || (defined(CONFIG_DVB_DRXK_MODULE) \ | 53 | #if defined(CONFIG_DVB_DRXK) || (defined(CONFIG_DVB_DRXK_MODULE) \ |
diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c index 60b868faeacf..1ab8154542da 100644 --- a/drivers/media/dvb/frontends/drxk_hard.c +++ b/drivers/media/dvb/frontends/drxk_hard.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/firmware.h> | 29 | #include <linux/firmware.h> |
30 | #include <linux/i2c.h> | 30 | #include <linux/i2c.h> |
31 | #include <linux/hardirq.h> | ||
31 | #include <asm/div64.h> | 32 | #include <asm/div64.h> |
32 | 33 | ||
33 | #include "dvb_frontend.h" | 34 | #include "dvb_frontend.h" |
@@ -308,16 +309,42 @@ static u32 Log10Times100(u32 x) | |||
308 | /* I2C **********************************************************************/ | 309 | /* I2C **********************************************************************/ |
309 | /****************************************************************************/ | 310 | /****************************************************************************/ |
310 | 311 | ||
311 | static int i2c_read1(struct i2c_adapter *adapter, u8 adr, u8 *val) | 312 | static int drxk_i2c_lock(struct drxk_state *state) |
313 | { | ||
314 | i2c_lock_adapter(state->i2c); | ||
315 | state->drxk_i2c_exclusive_lock = true; | ||
316 | |||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | static void drxk_i2c_unlock(struct drxk_state *state) | ||
321 | { | ||
322 | if (!state->drxk_i2c_exclusive_lock) | ||
323 | return; | ||
324 | |||
325 | i2c_unlock_adapter(state->i2c); | ||
326 | state->drxk_i2c_exclusive_lock = false; | ||
327 | } | ||
328 | |||
329 | static int drxk_i2c_transfer(struct drxk_state *state, struct i2c_msg *msgs, | ||
330 | unsigned len) | ||
331 | { | ||
332 | if (state->drxk_i2c_exclusive_lock) | ||
333 | return __i2c_transfer(state->i2c, msgs, len); | ||
334 | else | ||
335 | return i2c_transfer(state->i2c, msgs, len); | ||
336 | } | ||
337 | |||
338 | static int i2c_read1(struct drxk_state *state, u8 adr, u8 *val) | ||
312 | { | 339 | { |
313 | struct i2c_msg msgs[1] = { {.addr = adr, .flags = I2C_M_RD, | 340 | struct i2c_msg msgs[1] = { {.addr = adr, .flags = I2C_M_RD, |
314 | .buf = val, .len = 1} | 341 | .buf = val, .len = 1} |
315 | }; | 342 | }; |
316 | 343 | ||
317 | return i2c_transfer(adapter, msgs, 1); | 344 | return drxk_i2c_transfer(state, msgs, 1); |
318 | } | 345 | } |
319 | 346 | ||
320 | static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) | 347 | static int i2c_write(struct drxk_state *state, u8 adr, u8 *data, int len) |
321 | { | 348 | { |
322 | int status; | 349 | int status; |
323 | struct i2c_msg msg = { | 350 | struct i2c_msg msg = { |
@@ -330,7 +357,7 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) | |||
330 | printk(KERN_CONT " %02x", data[i]); | 357 | printk(KERN_CONT " %02x", data[i]); |
331 | printk(KERN_CONT "\n"); | 358 | printk(KERN_CONT "\n"); |
332 | } | 359 | } |
333 | status = i2c_transfer(adap, &msg, 1); | 360 | status = drxk_i2c_transfer(state, &msg, 1); |
334 | if (status >= 0 && status != 1) | 361 | if (status >= 0 && status != 1) |
335 | status = -EIO; | 362 | status = -EIO; |
336 | 363 | ||
@@ -340,7 +367,7 @@ static int i2c_write(struct i2c_adapter *adap, u8 adr, u8 *data, int len) | |||
340 | return status; | 367 | return status; |
341 | } | 368 | } |
342 | 369 | ||
343 | static int i2c_read(struct i2c_adapter *adap, | 370 | static int i2c_read(struct drxk_state *state, |
344 | u8 adr, u8 *msg, int len, u8 *answ, int alen) | 371 | u8 adr, u8 *msg, int len, u8 *answ, int alen) |
345 | { | 372 | { |
346 | int status; | 373 | int status; |
@@ -351,7 +378,7 @@ static int i2c_read(struct i2c_adapter *adap, | |||
351 | .buf = answ, .len = alen} | 378 | .buf = answ, .len = alen} |
352 | }; | 379 | }; |
353 | 380 | ||
354 | status = i2c_transfer(adap, msgs, 2); | 381 | status = drxk_i2c_transfer(state, msgs, 2); |
355 | if (status != 2) { | 382 | if (status != 2) { |
356 | if (debug > 2) | 383 | if (debug > 2) |
357 | printk(KERN_CONT ": ERROR!\n"); | 384 | printk(KERN_CONT ": ERROR!\n"); |
@@ -394,7 +421,7 @@ static int read16_flags(struct drxk_state *state, u32 reg, u16 *data, u8 flags) | |||
394 | len = 2; | 421 | len = 2; |
395 | } | 422 | } |
396 | dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); | 423 | dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); |
397 | status = i2c_read(state->i2c, adr, mm1, len, mm2, 2); | 424 | status = i2c_read(state, adr, mm1, len, mm2, 2); |
398 | if (status < 0) | 425 | if (status < 0) |
399 | return status; | 426 | return status; |
400 | if (data) | 427 | if (data) |
@@ -428,7 +455,7 @@ static int read32_flags(struct drxk_state *state, u32 reg, u32 *data, u8 flags) | |||
428 | len = 2; | 455 | len = 2; |
429 | } | 456 | } |
430 | dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); | 457 | dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags); |
431 | status = i2c_read(state->i2c, adr, mm1, len, mm2, 4); | 458 | status = i2c_read(state, adr, mm1, len, mm2, 4); |
432 | if (status < 0) | 459 | if (status < 0) |
433 | return status; | 460 | return status; |
434 | if (data) | 461 | if (data) |
@@ -464,7 +491,7 @@ static int write16_flags(struct drxk_state *state, u32 reg, u16 data, u8 flags) | |||
464 | mm[len + 1] = (data >> 8) & 0xff; | 491 | mm[len + 1] = (data >> 8) & 0xff; |
465 | 492 | ||
466 | dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg, data, flags); | 493 | dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg, data, flags); |
467 | return i2c_write(state->i2c, adr, mm, len + 2); | 494 | return i2c_write(state, adr, mm, len + 2); |
468 | } | 495 | } |
469 | 496 | ||
470 | static int write16(struct drxk_state *state, u32 reg, u16 data) | 497 | static int write16(struct drxk_state *state, u32 reg, u16 data) |
@@ -495,7 +522,7 @@ static int write32_flags(struct drxk_state *state, u32 reg, u32 data, u8 flags) | |||
495 | mm[len + 3] = (data >> 24) & 0xff; | 522 | mm[len + 3] = (data >> 24) & 0xff; |
496 | dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg, data, flags); | 523 | dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg, data, flags); |
497 | 524 | ||
498 | return i2c_write(state->i2c, adr, mm, len + 4); | 525 | return i2c_write(state, adr, mm, len + 4); |
499 | } | 526 | } |
500 | 527 | ||
501 | static int write32(struct drxk_state *state, u32 reg, u32 data) | 528 | static int write32(struct drxk_state *state, u32 reg, u32 data) |
@@ -542,7 +569,7 @@ static int write_block(struct drxk_state *state, u32 Address, | |||
542 | printk(KERN_CONT " %02x", pBlock[i]); | 569 | printk(KERN_CONT " %02x", pBlock[i]); |
543 | printk(KERN_CONT "\n"); | 570 | printk(KERN_CONT "\n"); |
544 | } | 571 | } |
545 | status = i2c_write(state->i2c, state->demod_address, | 572 | status = i2c_write(state, state->demod_address, |
546 | &state->Chunk[0], Chunk + AdrLength); | 573 | &state->Chunk[0], Chunk + AdrLength); |
547 | if (status < 0) { | 574 | if (status < 0) { |
548 | printk(KERN_ERR "drxk: %s: i2c write error at addr 0x%02x\n", | 575 | printk(KERN_ERR "drxk: %s: i2c write error at addr 0x%02x\n", |
@@ -568,17 +595,17 @@ int PowerUpDevice(struct drxk_state *state) | |||
568 | 595 | ||
569 | dprintk(1, "\n"); | 596 | dprintk(1, "\n"); |
570 | 597 | ||
571 | status = i2c_read1(state->i2c, state->demod_address, &data); | 598 | status = i2c_read1(state, state->demod_address, &data); |
572 | if (status < 0) { | 599 | if (status < 0) { |
573 | do { | 600 | do { |
574 | data = 0; | 601 | data = 0; |
575 | status = i2c_write(state->i2c, state->demod_address, | 602 | status = i2c_write(state, state->demod_address, |
576 | &data, 1); | 603 | &data, 1); |
577 | msleep(10); | 604 | msleep(10); |
578 | retryCount++; | 605 | retryCount++; |
579 | if (status < 0) | 606 | if (status < 0) |
580 | continue; | 607 | continue; |
581 | status = i2c_read1(state->i2c, state->demod_address, | 608 | status = i2c_read1(state, state->demod_address, |
582 | &data); | 609 | &data); |
583 | } while (status < 0 && | 610 | } while (status < 0 && |
584 | (retryCount < DRXK_MAX_RETRIES_POWERUP)); | 611 | (retryCount < DRXK_MAX_RETRIES_POWERUP)); |
@@ -932,7 +959,7 @@ static int GetDeviceCapabilities(struct drxk_state *state) | |||
932 | if (status < 0) | 959 | if (status < 0) |
933 | goto error; | 960 | goto error; |
934 | 961 | ||
935 | printk(KERN_ERR "drxk: status = 0x%08x\n", sioTopJtagidLo); | 962 | printk(KERN_INFO "drxk: status = 0x%08x\n", sioTopJtagidLo); |
936 | 963 | ||
937 | /* driver 0.9.0 */ | 964 | /* driver 0.9.0 */ |
938 | switch ((sioTopJtagidLo >> 29) & 0xF) { | 965 | switch ((sioTopJtagidLo >> 29) & 0xF) { |
@@ -2824,7 +2851,7 @@ static int ConfigureI2CBridge(struct drxk_state *state, bool bEnableBridge) | |||
2824 | dprintk(1, "\n"); | 2851 | dprintk(1, "\n"); |
2825 | 2852 | ||
2826 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | 2853 | if (state->m_DrxkState == DRXK_UNINITIALIZED) |
2827 | goto error; | 2854 | return 0; |
2828 | if (state->m_DrxkState == DRXK_POWERED_DOWN) | 2855 | if (state->m_DrxkState == DRXK_POWERED_DOWN) |
2829 | goto error; | 2856 | goto error; |
2830 | 2857 | ||
@@ -2977,7 +3004,7 @@ static int ADCSynchronization(struct drxk_state *state) | |||
2977 | status = read16(state, IQM_AF_CLKNEG__A, &clkNeg); | 3004 | status = read16(state, IQM_AF_CLKNEG__A, &clkNeg); |
2978 | if (status < 0) | 3005 | if (status < 0) |
2979 | goto error; | 3006 | goto error; |
2980 | if ((clkNeg | IQM_AF_CLKNEG_CLKNEGDATA__M) == | 3007 | if ((clkNeg & IQM_AF_CLKNEG_CLKNEGDATA__M) == |
2981 | IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS) { | 3008 | IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS) { |
2982 | clkNeg &= (~(IQM_AF_CLKNEG_CLKNEGDATA__M)); | 3009 | clkNeg &= (~(IQM_AF_CLKNEG_CLKNEGDATA__M)); |
2983 | clkNeg |= | 3010 | clkNeg |= |
@@ -5361,7 +5388,7 @@ static int GetQAMLockStatus(struct drxk_state *state, u32 *pLockStatus) | |||
5361 | SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK, 0, NULL, 2, | 5388 | SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK, 0, NULL, 2, |
5362 | Result); | 5389 | Result); |
5363 | if (status < 0) | 5390 | if (status < 0) |
5364 | printk(KERN_ERR "drxk: %s status = %08x\n", __func__, status); | 5391 | printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); |
5365 | 5392 | ||
5366 | if (Result[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED) { | 5393 | if (Result[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED) { |
5367 | /* 0x0000 NOT LOCKED */ | 5394 | /* 0x0000 NOT LOCKED */ |
@@ -5388,12 +5415,67 @@ static int GetQAMLockStatus(struct drxk_state *state, u32 *pLockStatus) | |||
5388 | #define QAM_LOCKRANGE__M 0x10 | 5415 | #define QAM_LOCKRANGE__M 0x10 |
5389 | #define QAM_LOCKRANGE_NORMAL 0x10 | 5416 | #define QAM_LOCKRANGE_NORMAL 0x10 |
5390 | 5417 | ||
5418 | static int QAMDemodulatorCommand(struct drxk_state *state, | ||
5419 | int numberOfParameters) | ||
5420 | { | ||
5421 | int status; | ||
5422 | u16 cmdResult; | ||
5423 | u16 setParamParameters[4] = { 0, 0, 0, 0 }; | ||
5424 | |||
5425 | setParamParameters[0] = state->m_Constellation; /* modulation */ | ||
5426 | setParamParameters[1] = DRXK_QAM_I12_J17; /* interleave mode */ | ||
5427 | |||
5428 | if (numberOfParameters == 2) { | ||
5429 | u16 setEnvParameters[1] = { 0 }; | ||
5430 | |||
5431 | if (state->m_OperationMode == OM_QAM_ITU_C) | ||
5432 | setEnvParameters[0] = QAM_TOP_ANNEX_C; | ||
5433 | else | ||
5434 | setEnvParameters[0] = QAM_TOP_ANNEX_A; | ||
5435 | |||
5436 | status = scu_command(state, | ||
5437 | SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, | ||
5438 | 1, setEnvParameters, 1, &cmdResult); | ||
5439 | if (status < 0) | ||
5440 | goto error; | ||
5441 | |||
5442 | status = scu_command(state, | ||
5443 | SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, | ||
5444 | numberOfParameters, setParamParameters, | ||
5445 | 1, &cmdResult); | ||
5446 | } else if (numberOfParameters == 4) { | ||
5447 | if (state->m_OperationMode == OM_QAM_ITU_C) | ||
5448 | setParamParameters[2] = QAM_TOP_ANNEX_C; | ||
5449 | else | ||
5450 | setParamParameters[2] = QAM_TOP_ANNEX_A; | ||
5451 | |||
5452 | setParamParameters[3] |= (QAM_MIRROR_AUTO_ON); | ||
5453 | /* Env parameters */ | ||
5454 | /* check for LOCKRANGE Extented */ | ||
5455 | /* setParamParameters[3] |= QAM_LOCKRANGE_NORMAL; */ | ||
5456 | |||
5457 | status = scu_command(state, | ||
5458 | SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, | ||
5459 | numberOfParameters, setParamParameters, | ||
5460 | 1, &cmdResult); | ||
5461 | } else { | ||
5462 | printk(KERN_WARNING "drxk: Unknown QAM demodulator parameter " | ||
5463 | "count %d\n", numberOfParameters); | ||
5464 | } | ||
5465 | |||
5466 | error: | ||
5467 | if (status < 0) | ||
5468 | printk(KERN_WARNING "drxk: Warning %d on %s\n", | ||
5469 | status, __func__); | ||
5470 | return status; | ||
5471 | } | ||
5472 | |||
5391 | static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, | 5473 | static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, |
5392 | s32 tunerFreqOffset) | 5474 | s32 tunerFreqOffset) |
5393 | { | 5475 | { |
5394 | int status; | 5476 | int status; |
5395 | u16 setParamParameters[4] = { 0, 0, 0, 0 }; | ||
5396 | u16 cmdResult; | 5477 | u16 cmdResult; |
5478 | int qamDemodParamCount = state->qam_demod_parameter_count; | ||
5397 | 5479 | ||
5398 | dprintk(1, "\n"); | 5480 | dprintk(1, "\n"); |
5399 | /* | 5481 | /* |
@@ -5445,34 +5527,42 @@ static int SetQAM(struct drxk_state *state, u16 IntermediateFreqkHz, | |||
5445 | } | 5527 | } |
5446 | if (status < 0) | 5528 | if (status < 0) |
5447 | goto error; | 5529 | goto error; |
5448 | setParamParameters[0] = state->m_Constellation; /* modulation */ | ||
5449 | setParamParameters[1] = DRXK_QAM_I12_J17; /* interleave mode */ | ||
5450 | if (state->m_OperationMode == OM_QAM_ITU_C) | ||
5451 | setParamParameters[2] = QAM_TOP_ANNEX_C; | ||
5452 | else | ||
5453 | setParamParameters[2] = QAM_TOP_ANNEX_A; | ||
5454 | setParamParameters[3] |= (QAM_MIRROR_AUTO_ON); | ||
5455 | /* Env parameters */ | ||
5456 | /* check for LOCKRANGE Extented */ | ||
5457 | /* setParamParameters[3] |= QAM_LOCKRANGE_NORMAL; */ | ||
5458 | 5530 | ||
5459 | status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, 4, setParamParameters, 1, &cmdResult); | 5531 | /* Use the 4-parameter if it's requested or we're probing for |
5460 | if (status < 0) { | 5532 | * the correct command. */ |
5461 | /* Fall-back to the simpler call */ | 5533 | if (state->qam_demod_parameter_count == 4 |
5462 | if (state->m_OperationMode == OM_QAM_ITU_C) | 5534 | || !state->qam_demod_parameter_count) { |
5463 | setParamParameters[0] = QAM_TOP_ANNEX_C; | 5535 | qamDemodParamCount = 4; |
5464 | else | 5536 | status = QAMDemodulatorCommand(state, qamDemodParamCount); |
5465 | setParamParameters[0] = QAM_TOP_ANNEX_A; | 5537 | } |
5466 | status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV, 1, setParamParameters, 1, &cmdResult); | ||
5467 | if (status < 0) | ||
5468 | goto error; | ||
5469 | 5538 | ||
5470 | setParamParameters[0] = state->m_Constellation; /* modulation */ | 5539 | /* Use the 2-parameter command if it was requested or if we're |
5471 | setParamParameters[1] = DRXK_QAM_I12_J17; /* interleave mode */ | 5540 | * probing for the correct command and the 4-parameter command |
5472 | status = scu_command(state, SCU_RAM_COMMAND_STANDARD_QAM | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM, 2, setParamParameters, 1, &cmdResult); | 5541 | * failed. */ |
5542 | if (state->qam_demod_parameter_count == 2 | ||
5543 | || (!state->qam_demod_parameter_count && status < 0)) { | ||
5544 | qamDemodParamCount = 2; | ||
5545 | status = QAMDemodulatorCommand(state, qamDemodParamCount); | ||
5473 | } | 5546 | } |
5474 | if (status < 0) | 5547 | |
5548 | if (status < 0) { | ||
5549 | dprintk(1, "Could not set demodulator parameters. Make " | ||
5550 | "sure qam_demod_parameter_count (%d) is correct for " | ||
5551 | "your firmware (%s).\n", | ||
5552 | state->qam_demod_parameter_count, | ||
5553 | state->microcode_name); | ||
5475 | goto error; | 5554 | goto error; |
5555 | } else if (!state->qam_demod_parameter_count) { | ||
5556 | dprintk(1, "Auto-probing the correct QAM demodulator command " | ||
5557 | "parameters was successful - using %d parameters.\n", | ||
5558 | qamDemodParamCount); | ||
5559 | |||
5560 | /* | ||
5561 | * One of our commands was successful. We don't need to | ||
5562 | * auto-probe anymore, now that we got the correct command. | ||
5563 | */ | ||
5564 | state->qam_demod_parameter_count = qamDemodParamCount; | ||
5565 | } | ||
5476 | 5566 | ||
5477 | /* | 5567 | /* |
5478 | * STEP 3: enable the system in a mode where the ADC provides valid | 5568 | * STEP 3: enable the system in a mode where the ADC provides valid |
@@ -5968,34 +6058,15 @@ error: | |||
5968 | return status; | 6058 | return status; |
5969 | } | 6059 | } |
5970 | 6060 | ||
5971 | static int load_microcode(struct drxk_state *state, const char *mc_name) | ||
5972 | { | ||
5973 | const struct firmware *fw = NULL; | ||
5974 | int err = 0; | ||
5975 | |||
5976 | dprintk(1, "\n"); | ||
5977 | |||
5978 | err = request_firmware(&fw, mc_name, state->i2c->dev.parent); | ||
5979 | if (err < 0) { | ||
5980 | printk(KERN_ERR | ||
5981 | "drxk: Could not load firmware file %s.\n", mc_name); | ||
5982 | printk(KERN_INFO | ||
5983 | "drxk: Copy %s to your hotplug directory!\n", mc_name); | ||
5984 | return err; | ||
5985 | } | ||
5986 | err = DownloadMicrocode(state, fw->data, fw->size); | ||
5987 | release_firmware(fw); | ||
5988 | return err; | ||
5989 | } | ||
5990 | |||
5991 | static int init_drxk(struct drxk_state *state) | 6061 | static int init_drxk(struct drxk_state *state) |
5992 | { | 6062 | { |
5993 | int status = 0; | 6063 | int status = 0, n = 0; |
5994 | enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM; | 6064 | enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM; |
5995 | u16 driverVersion; | 6065 | u16 driverVersion; |
5996 | 6066 | ||
5997 | dprintk(1, "\n"); | 6067 | dprintk(1, "\n"); |
5998 | if ((state->m_DrxkState == DRXK_UNINITIALIZED)) { | 6068 | if ((state->m_DrxkState == DRXK_UNINITIALIZED)) { |
6069 | drxk_i2c_lock(state); | ||
5999 | status = PowerUpDevice(state); | 6070 | status = PowerUpDevice(state); |
6000 | if (status < 0) | 6071 | if (status < 0) |
6001 | goto error; | 6072 | goto error; |
@@ -6073,8 +6144,12 @@ static int init_drxk(struct drxk_state *state) | |||
6073 | if (status < 0) | 6144 | if (status < 0) |
6074 | goto error; | 6145 | goto error; |
6075 | 6146 | ||
6076 | if (state->microcode_name) | 6147 | if (state->fw) { |
6077 | load_microcode(state, state->microcode_name); | 6148 | status = DownloadMicrocode(state, state->fw->data, |
6149 | state->fw->size); | ||
6150 | if (status < 0) | ||
6151 | goto error; | ||
6152 | } | ||
6078 | 6153 | ||
6079 | /* disable token-ring bus through OFDM block for possible ucode upload */ | 6154 | /* disable token-ring bus through OFDM block for possible ucode upload */ |
6080 | status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, SIO_OFDM_SH_OFDM_RING_ENABLE_OFF); | 6155 | status = write16(state, SIO_OFDM_SH_OFDM_RING_ENABLE__A, SIO_OFDM_SH_OFDM_RING_ENABLE_OFF); |
@@ -6167,19 +6242,71 @@ static int init_drxk(struct drxk_state *state) | |||
6167 | state->m_DrxkState = DRXK_POWERED_DOWN; | 6242 | state->m_DrxkState = DRXK_POWERED_DOWN; |
6168 | } else | 6243 | } else |
6169 | state->m_DrxkState = DRXK_STOPPED; | 6244 | state->m_DrxkState = DRXK_STOPPED; |
6245 | |||
6246 | /* Initialize the supported delivery systems */ | ||
6247 | n = 0; | ||
6248 | if (state->m_hasDVBC) { | ||
6249 | state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_A; | ||
6250 | state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_C; | ||
6251 | strlcat(state->frontend.ops.info.name, " DVB-C", | ||
6252 | sizeof(state->frontend.ops.info.name)); | ||
6253 | } | ||
6254 | if (state->m_hasDVBT) { | ||
6255 | state->frontend.ops.delsys[n++] = SYS_DVBT; | ||
6256 | strlcat(state->frontend.ops.info.name, " DVB-T", | ||
6257 | sizeof(state->frontend.ops.info.name)); | ||
6258 | } | ||
6259 | drxk_i2c_unlock(state); | ||
6170 | } | 6260 | } |
6171 | error: | 6261 | error: |
6172 | if (status < 0) | 6262 | if (status < 0) { |
6263 | state->m_DrxkState = DRXK_NO_DEV; | ||
6264 | drxk_i2c_unlock(state); | ||
6173 | printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); | 6265 | printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); |
6266 | } | ||
6174 | 6267 | ||
6175 | return status; | 6268 | return status; |
6176 | } | 6269 | } |
6177 | 6270 | ||
6271 | static void load_firmware_cb(const struct firmware *fw, | ||
6272 | void *context) | ||
6273 | { | ||
6274 | struct drxk_state *state = context; | ||
6275 | |||
6276 | dprintk(1, ": %s\n", fw ? "firmware loaded" : "firmware not loaded"); | ||
6277 | if (!fw) { | ||
6278 | printk(KERN_ERR | ||
6279 | "drxk: Could not load firmware file %s.\n", | ||
6280 | state->microcode_name); | ||
6281 | printk(KERN_INFO | ||
6282 | "drxk: Copy %s to your hotplug directory!\n", | ||
6283 | state->microcode_name); | ||
6284 | state->microcode_name = NULL; | ||
6285 | |||
6286 | /* | ||
6287 | * As firmware is now load asynchronous, it is not possible | ||
6288 | * anymore to fail at frontend attach. We might silently | ||
6289 | * return here, and hope that the driver won't crash. | ||
6290 | * We might also change all DVB callbacks to return -ENODEV | ||
6291 | * if the device is not initialized. | ||
6292 | * As the DRX-K devices have their own internal firmware, | ||
6293 | * let's just hope that it will match a firmware revision | ||
6294 | * compatible with this driver and proceed. | ||
6295 | */ | ||
6296 | } | ||
6297 | state->fw = fw; | ||
6298 | |||
6299 | init_drxk(state); | ||
6300 | } | ||
6301 | |||
6178 | static void drxk_release(struct dvb_frontend *fe) | 6302 | static void drxk_release(struct dvb_frontend *fe) |
6179 | { | 6303 | { |
6180 | struct drxk_state *state = fe->demodulator_priv; | 6304 | struct drxk_state *state = fe->demodulator_priv; |
6181 | 6305 | ||
6182 | dprintk(1, "\n"); | 6306 | dprintk(1, "\n"); |
6307 | if (state->fw) | ||
6308 | release_firmware(state->fw); | ||
6309 | |||
6183 | kfree(state); | 6310 | kfree(state); |
6184 | } | 6311 | } |
6185 | 6312 | ||
@@ -6188,6 +6315,12 @@ static int drxk_sleep(struct dvb_frontend *fe) | |||
6188 | struct drxk_state *state = fe->demodulator_priv; | 6315 | struct drxk_state *state = fe->demodulator_priv; |
6189 | 6316 | ||
6190 | dprintk(1, "\n"); | 6317 | dprintk(1, "\n"); |
6318 | |||
6319 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6320 | return -ENODEV; | ||
6321 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6322 | return 0; | ||
6323 | |||
6191 | ShutDown(state); | 6324 | ShutDown(state); |
6192 | return 0; | 6325 | return 0; |
6193 | } | 6326 | } |
@@ -6196,7 +6329,11 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) | |||
6196 | { | 6329 | { |
6197 | struct drxk_state *state = fe->demodulator_priv; | 6330 | struct drxk_state *state = fe->demodulator_priv; |
6198 | 6331 | ||
6199 | dprintk(1, "%s\n", enable ? "enable" : "disable"); | 6332 | dprintk(1, ": %s\n", enable ? "enable" : "disable"); |
6333 | |||
6334 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6335 | return -ENODEV; | ||
6336 | |||
6200 | return ConfigureI2CBridge(state, enable ? true : false); | 6337 | return ConfigureI2CBridge(state, enable ? true : false); |
6201 | } | 6338 | } |
6202 | 6339 | ||
@@ -6209,6 +6346,12 @@ static int drxk_set_parameters(struct dvb_frontend *fe) | |||
6209 | 6346 | ||
6210 | dprintk(1, "\n"); | 6347 | dprintk(1, "\n"); |
6211 | 6348 | ||
6349 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6350 | return -ENODEV; | ||
6351 | |||
6352 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6353 | return -EAGAIN; | ||
6354 | |||
6212 | if (!fe->ops.tuner_ops.get_if_frequency) { | 6355 | if (!fe->ops.tuner_ops.get_if_frequency) { |
6213 | printk(KERN_ERR | 6356 | printk(KERN_ERR |
6214 | "drxk: Error: get_if_frequency() not defined at tuner. Can't work without it!\n"); | 6357 | "drxk: Error: get_if_frequency() not defined at tuner. Can't work without it!\n"); |
@@ -6262,6 +6405,12 @@ static int drxk_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
6262 | u32 stat; | 6405 | u32 stat; |
6263 | 6406 | ||
6264 | dprintk(1, "\n"); | 6407 | dprintk(1, "\n"); |
6408 | |||
6409 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6410 | return -ENODEV; | ||
6411 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6412 | return -EAGAIN; | ||
6413 | |||
6265 | *status = 0; | 6414 | *status = 0; |
6266 | GetLockStatus(state, &stat, 0); | 6415 | GetLockStatus(state, &stat, 0); |
6267 | if (stat == MPEG_LOCK) | 6416 | if (stat == MPEG_LOCK) |
@@ -6275,8 +6424,15 @@ static int drxk_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
6275 | 6424 | ||
6276 | static int drxk_read_ber(struct dvb_frontend *fe, u32 *ber) | 6425 | static int drxk_read_ber(struct dvb_frontend *fe, u32 *ber) |
6277 | { | 6426 | { |
6427 | struct drxk_state *state = fe->demodulator_priv; | ||
6428 | |||
6278 | dprintk(1, "\n"); | 6429 | dprintk(1, "\n"); |
6279 | 6430 | ||
6431 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6432 | return -ENODEV; | ||
6433 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6434 | return -EAGAIN; | ||
6435 | |||
6280 | *ber = 0; | 6436 | *ber = 0; |
6281 | return 0; | 6437 | return 0; |
6282 | } | 6438 | } |
@@ -6288,6 +6444,12 @@ static int drxk_read_signal_strength(struct dvb_frontend *fe, | |||
6288 | u32 val = 0; | 6444 | u32 val = 0; |
6289 | 6445 | ||
6290 | dprintk(1, "\n"); | 6446 | dprintk(1, "\n"); |
6447 | |||
6448 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6449 | return -ENODEV; | ||
6450 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6451 | return -EAGAIN; | ||
6452 | |||
6291 | ReadIFAgc(state, &val); | 6453 | ReadIFAgc(state, &val); |
6292 | *strength = val & 0xffff; | 6454 | *strength = val & 0xffff; |
6293 | return 0; | 6455 | return 0; |
@@ -6299,6 +6461,12 @@ static int drxk_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
6299 | s32 snr2; | 6461 | s32 snr2; |
6300 | 6462 | ||
6301 | dprintk(1, "\n"); | 6463 | dprintk(1, "\n"); |
6464 | |||
6465 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6466 | return -ENODEV; | ||
6467 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6468 | return -EAGAIN; | ||
6469 | |||
6302 | GetSignalToNoise(state, &snr2); | 6470 | GetSignalToNoise(state, &snr2); |
6303 | *snr = snr2 & 0xffff; | 6471 | *snr = snr2 & 0xffff; |
6304 | return 0; | 6472 | return 0; |
@@ -6310,6 +6478,12 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
6310 | u16 err; | 6478 | u16 err; |
6311 | 6479 | ||
6312 | dprintk(1, "\n"); | 6480 | dprintk(1, "\n"); |
6481 | |||
6482 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6483 | return -ENODEV; | ||
6484 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6485 | return -EAGAIN; | ||
6486 | |||
6313 | DVBTQAMGetAccPktErr(state, &err); | 6487 | DVBTQAMGetAccPktErr(state, &err); |
6314 | *ucblocks = (u32) err; | 6488 | *ucblocks = (u32) err; |
6315 | return 0; | 6489 | return 0; |
@@ -6318,9 +6492,16 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
6318 | static int drxk_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings | 6492 | static int drxk_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings |
6319 | *sets) | 6493 | *sets) |
6320 | { | 6494 | { |
6495 | struct drxk_state *state = fe->demodulator_priv; | ||
6321 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; | 6496 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; |
6322 | 6497 | ||
6323 | dprintk(1, "\n"); | 6498 | dprintk(1, "\n"); |
6499 | |||
6500 | if (state->m_DrxkState == DRXK_NO_DEV) | ||
6501 | return -ENODEV; | ||
6502 | if (state->m_DrxkState == DRXK_UNINITIALIZED) | ||
6503 | return -EAGAIN; | ||
6504 | |||
6324 | switch (p->delivery_system) { | 6505 | switch (p->delivery_system) { |
6325 | case SYS_DVBC_ANNEX_A: | 6506 | case SYS_DVBC_ANNEX_A: |
6326 | case SYS_DVBC_ANNEX_C: | 6507 | case SYS_DVBC_ANNEX_C: |
@@ -6371,10 +6552,9 @@ static struct dvb_frontend_ops drxk_ops = { | |||
6371 | struct dvb_frontend *drxk_attach(const struct drxk_config *config, | 6552 | struct dvb_frontend *drxk_attach(const struct drxk_config *config, |
6372 | struct i2c_adapter *i2c) | 6553 | struct i2c_adapter *i2c) |
6373 | { | 6554 | { |
6374 | int n; | ||
6375 | |||
6376 | struct drxk_state *state = NULL; | 6555 | struct drxk_state *state = NULL; |
6377 | u8 adr = config->adr; | 6556 | u8 adr = config->adr; |
6557 | int status; | ||
6378 | 6558 | ||
6379 | dprintk(1, "\n"); | 6559 | dprintk(1, "\n"); |
6380 | state = kzalloc(sizeof(struct drxk_state), GFP_KERNEL); | 6560 | state = kzalloc(sizeof(struct drxk_state), GFP_KERNEL); |
@@ -6385,6 +6565,7 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config, | |||
6385 | state->demod_address = adr; | 6565 | state->demod_address = adr; |
6386 | state->single_master = config->single_master; | 6566 | state->single_master = config->single_master; |
6387 | state->microcode_name = config->microcode_name; | 6567 | state->microcode_name = config->microcode_name; |
6568 | state->qam_demod_parameter_count = config->qam_demod_parameter_count; | ||
6388 | state->no_i2c_bridge = config->no_i2c_bridge; | 6569 | state->no_i2c_bridge = config->no_i2c_bridge; |
6389 | state->antenna_gpio = config->antenna_gpio; | 6570 | state->antenna_gpio = config->antenna_gpio; |
6390 | state->antenna_dvbt = config->antenna_dvbt; | 6571 | state->antenna_dvbt = config->antenna_dvbt; |
@@ -6425,22 +6606,21 @@ struct dvb_frontend *drxk_attach(const struct drxk_config *config, | |||
6425 | state->frontend.demodulator_priv = state; | 6606 | state->frontend.demodulator_priv = state; |
6426 | 6607 | ||
6427 | init_state(state); | 6608 | init_state(state); |
6428 | if (init_drxk(state) < 0) | ||
6429 | goto error; | ||
6430 | 6609 | ||
6431 | /* Initialize the supported delivery systems */ | 6610 | /* Load firmware and initialize DRX-K */ |
6432 | n = 0; | 6611 | if (state->microcode_name) { |
6433 | if (state->m_hasDVBC) { | 6612 | status = request_firmware_nowait(THIS_MODULE, 1, |
6434 | state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_A; | 6613 | state->microcode_name, |
6435 | state->frontend.ops.delsys[n++] = SYS_DVBC_ANNEX_C; | 6614 | state->i2c->dev.parent, |
6436 | strlcat(state->frontend.ops.info.name, " DVB-C", | 6615 | GFP_KERNEL, |
6437 | sizeof(state->frontend.ops.info.name)); | 6616 | state, load_firmware_cb); |
6438 | } | 6617 | if (status < 0) { |
6439 | if (state->m_hasDVBT) { | 6618 | printk(KERN_ERR |
6440 | state->frontend.ops.delsys[n++] = SYS_DVBT; | 6619 | "drxk: failed to request a firmware\n"); |
6441 | strlcat(state->frontend.ops.info.name, " DVB-T", | 6620 | return NULL; |
6442 | sizeof(state->frontend.ops.info.name)); | 6621 | } |
6443 | } | 6622 | } else if (init_drxk(state) < 0) |
6623 | goto error; | ||
6444 | 6624 | ||
6445 | printk(KERN_INFO "drxk: frontend initialized.\n"); | 6625 | printk(KERN_INFO "drxk: frontend initialized.\n"); |
6446 | return &state->frontend; | 6626 | return &state->frontend; |
diff --git a/drivers/media/dvb/frontends/drxk_hard.h b/drivers/media/dvb/frontends/drxk_hard.h index 4bbf841de83a..6bb9fc4a7b96 100644 --- a/drivers/media/dvb/frontends/drxk_hard.h +++ b/drivers/media/dvb/frontends/drxk_hard.h | |||
@@ -94,7 +94,15 @@ enum DRXPowerMode { | |||
94 | 94 | ||
95 | 95 | ||
96 | enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF }; | 96 | enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF }; |
97 | enum EDrxkState { DRXK_UNINITIALIZED = 0, DRXK_STOPPED, DRXK_DTV_STARTED, DRXK_ATV_STARTED, DRXK_POWERED_DOWN }; | 97 | enum EDrxkState { |
98 | DRXK_UNINITIALIZED = 0, | ||
99 | DRXK_STOPPED, | ||
100 | DRXK_DTV_STARTED, | ||
101 | DRXK_ATV_STARTED, | ||
102 | DRXK_POWERED_DOWN, | ||
103 | DRXK_NO_DEV /* If drxk init failed */ | ||
104 | }; | ||
105 | |||
98 | enum EDrxkCoefArrayIndex { | 106 | enum EDrxkCoefArrayIndex { |
99 | DRXK_COEF_IDX_MN = 0, | 107 | DRXK_COEF_IDX_MN = 0, |
100 | DRXK_COEF_IDX_FM , | 108 | DRXK_COEF_IDX_FM , |
@@ -325,6 +333,9 @@ struct drxk_state { | |||
325 | 333 | ||
326 | enum DRXPowerMode m_currentPowerMode; | 334 | enum DRXPowerMode m_currentPowerMode; |
327 | 335 | ||
336 | /* when true, avoids other devices to use the I2C bus */ | ||
337 | bool drxk_i2c_exclusive_lock; | ||
338 | |||
328 | /* | 339 | /* |
329 | * Configurable parameters at the driver. They stores the values found | 340 | * Configurable parameters at the driver. They stores the values found |
330 | * at struct drxk_config. | 341 | * at struct drxk_config. |
@@ -338,7 +349,11 @@ struct drxk_state { | |||
338 | bool antenna_dvbt; | 349 | bool antenna_dvbt; |
339 | u16 antenna_gpio; | 350 | u16 antenna_gpio; |
340 | 351 | ||
352 | /* Firmware */ | ||
341 | const char *microcode_name; | 353 | const char *microcode_name; |
354 | struct completion fw_wait_load; | ||
355 | const struct firmware *fw; | ||
356 | int qam_demod_parameter_count; | ||
342 | }; | 357 | }; |
343 | 358 | ||
344 | #define NEVER_LOCK 0 | 359 | #define NEVER_LOCK 0 |
diff --git a/drivers/media/dvb/frontends/rtl2832.c b/drivers/media/dvb/frontends/rtl2832.c new file mode 100644 index 000000000000..2da592fb38ad --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.c | |||
@@ -0,0 +1,789 @@ | |||
1 | /* | ||
2 | * Realtek RTL2832 DVB-T demodulator driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include "rtl2832_priv.h" | ||
22 | #include <linux/bitops.h> | ||
23 | |||
24 | int rtl2832_debug; | ||
25 | module_param_named(debug, rtl2832_debug, int, 0644); | ||
26 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | ||
27 | |||
28 | #define REG_MASK(b) (BIT(b + 1) - 1) | ||
29 | |||
30 | static const struct rtl2832_reg_entry registers[] = { | ||
31 | [DVBT_SOFT_RST] = {0x1, 0x1, 2, 2}, | ||
32 | [DVBT_IIC_REPEAT] = {0x1, 0x1, 3, 3}, | ||
33 | [DVBT_TR_WAIT_MIN_8K] = {0x1, 0x88, 11, 2}, | ||
34 | [DVBT_RSD_BER_FAIL_VAL] = {0x1, 0x8f, 15, 0}, | ||
35 | [DVBT_EN_BK_TRK] = {0x1, 0xa6, 7, 7}, | ||
36 | [DVBT_AD_EN_REG] = {0x0, 0x8, 7, 7}, | ||
37 | [DVBT_AD_EN_REG1] = {0x0, 0x8, 6, 6}, | ||
38 | [DVBT_EN_BBIN] = {0x1, 0xb1, 0, 0}, | ||
39 | [DVBT_MGD_THD0] = {0x1, 0x95, 7, 0}, | ||
40 | [DVBT_MGD_THD1] = {0x1, 0x96, 7, 0}, | ||
41 | [DVBT_MGD_THD2] = {0x1, 0x97, 7, 0}, | ||
42 | [DVBT_MGD_THD3] = {0x1, 0x98, 7, 0}, | ||
43 | [DVBT_MGD_THD4] = {0x1, 0x99, 7, 0}, | ||
44 | [DVBT_MGD_THD5] = {0x1, 0x9a, 7, 0}, | ||
45 | [DVBT_MGD_THD6] = {0x1, 0x9b, 7, 0}, | ||
46 | [DVBT_MGD_THD7] = {0x1, 0x9c, 7, 0}, | ||
47 | [DVBT_EN_CACQ_NOTCH] = {0x1, 0x61, 4, 4}, | ||
48 | [DVBT_AD_AV_REF] = {0x0, 0x9, 6, 0}, | ||
49 | [DVBT_REG_PI] = {0x0, 0xa, 2, 0}, | ||
50 | [DVBT_PIP_ON] = {0x0, 0x21, 3, 3}, | ||
51 | [DVBT_SCALE1_B92] = {0x2, 0x92, 7, 0}, | ||
52 | [DVBT_SCALE1_B93] = {0x2, 0x93, 7, 0}, | ||
53 | [DVBT_SCALE1_BA7] = {0x2, 0xa7, 7, 0}, | ||
54 | [DVBT_SCALE1_BA9] = {0x2, 0xa9, 7, 0}, | ||
55 | [DVBT_SCALE1_BAA] = {0x2, 0xaa, 7, 0}, | ||
56 | [DVBT_SCALE1_BAB] = {0x2, 0xab, 7, 0}, | ||
57 | [DVBT_SCALE1_BAC] = {0x2, 0xac, 7, 0}, | ||
58 | [DVBT_SCALE1_BB0] = {0x2, 0xb0, 7, 0}, | ||
59 | [DVBT_SCALE1_BB1] = {0x2, 0xb1, 7, 0}, | ||
60 | [DVBT_KB_P1] = {0x1, 0x64, 3, 1}, | ||
61 | [DVBT_KB_P2] = {0x1, 0x64, 6, 4}, | ||
62 | [DVBT_KB_P3] = {0x1, 0x65, 2, 0}, | ||
63 | [DVBT_OPT_ADC_IQ] = {0x0, 0x6, 5, 4}, | ||
64 | [DVBT_AD_AVI] = {0x0, 0x9, 1, 0}, | ||
65 | [DVBT_AD_AVQ] = {0x0, 0x9, 3, 2}, | ||
66 | [DVBT_K1_CR_STEP12] = {0x2, 0xad, 9, 4}, | ||
67 | [DVBT_TRK_KS_P2] = {0x1, 0x6f, 2, 0}, | ||
68 | [DVBT_TRK_KS_I2] = {0x1, 0x70, 5, 3}, | ||
69 | [DVBT_TR_THD_SET2] = {0x1, 0x72, 3, 0}, | ||
70 | [DVBT_TRK_KC_P2] = {0x1, 0x73, 5, 3}, | ||
71 | [DVBT_TRK_KC_I2] = {0x1, 0x75, 2, 0}, | ||
72 | [DVBT_CR_THD_SET2] = {0x1, 0x76, 7, 6}, | ||
73 | [DVBT_PSET_IFFREQ] = {0x1, 0x19, 21, 0}, | ||
74 | [DVBT_SPEC_INV] = {0x1, 0x15, 0, 0}, | ||
75 | [DVBT_RSAMP_RATIO] = {0x1, 0x9f, 27, 2}, | ||
76 | [DVBT_CFREQ_OFF_RATIO] = {0x1, 0x9d, 23, 4}, | ||
77 | [DVBT_FSM_STAGE] = {0x3, 0x51, 6, 3}, | ||
78 | [DVBT_RX_CONSTEL] = {0x3, 0x3c, 3, 2}, | ||
79 | [DVBT_RX_HIER] = {0x3, 0x3c, 6, 4}, | ||
80 | [DVBT_RX_C_RATE_LP] = {0x3, 0x3d, 2, 0}, | ||
81 | [DVBT_RX_C_RATE_HP] = {0x3, 0x3d, 5, 3}, | ||
82 | [DVBT_GI_IDX] = {0x3, 0x51, 1, 0}, | ||
83 | [DVBT_FFT_MODE_IDX] = {0x3, 0x51, 2, 2}, | ||
84 | [DVBT_RSD_BER_EST] = {0x3, 0x4e, 15, 0}, | ||
85 | [DVBT_CE_EST_EVM] = {0x4, 0xc, 15, 0}, | ||
86 | [DVBT_RF_AGC_VAL] = {0x3, 0x5b, 13, 0}, | ||
87 | [DVBT_IF_AGC_VAL] = {0x3, 0x59, 13, 0}, | ||
88 | [DVBT_DAGC_VAL] = {0x3, 0x5, 7, 0}, | ||
89 | [DVBT_SFREQ_OFF] = {0x3, 0x18, 13, 0}, | ||
90 | [DVBT_CFREQ_OFF] = {0x3, 0x5f, 17, 0}, | ||
91 | [DVBT_POLAR_RF_AGC] = {0x0, 0xe, 1, 1}, | ||
92 | [DVBT_POLAR_IF_AGC] = {0x0, 0xe, 0, 0}, | ||
93 | [DVBT_AAGC_HOLD] = {0x1, 0x4, 5, 5}, | ||
94 | [DVBT_EN_RF_AGC] = {0x1, 0x4, 6, 6}, | ||
95 | [DVBT_EN_IF_AGC] = {0x1, 0x4, 7, 7}, | ||
96 | [DVBT_IF_AGC_MIN] = {0x1, 0x8, 7, 0}, | ||
97 | [DVBT_IF_AGC_MAX] = {0x1, 0x9, 7, 0}, | ||
98 | [DVBT_RF_AGC_MIN] = {0x1, 0xa, 7, 0}, | ||
99 | [DVBT_RF_AGC_MAX] = {0x1, 0xb, 7, 0}, | ||
100 | [DVBT_IF_AGC_MAN] = {0x1, 0xc, 6, 6}, | ||
101 | [DVBT_IF_AGC_MAN_VAL] = {0x1, 0xc, 13, 0}, | ||
102 | [DVBT_RF_AGC_MAN] = {0x1, 0xe, 6, 6}, | ||
103 | [DVBT_RF_AGC_MAN_VAL] = {0x1, 0xe, 13, 0}, | ||
104 | [DVBT_DAGC_TRG_VAL] = {0x1, 0x12, 7, 0}, | ||
105 | [DVBT_AGC_TARG_VAL_0] = {0x1, 0x2, 0, 0}, | ||
106 | [DVBT_AGC_TARG_VAL_8_1] = {0x1, 0x3, 7, 0}, | ||
107 | [DVBT_AAGC_LOOP_GAIN] = {0x1, 0xc7, 5, 1}, | ||
108 | [DVBT_LOOP_GAIN2_3_0] = {0x1, 0x4, 4, 1}, | ||
109 | [DVBT_LOOP_GAIN2_4] = {0x1, 0x5, 7, 7}, | ||
110 | [DVBT_LOOP_GAIN3] = {0x1, 0xc8, 4, 0}, | ||
111 | [DVBT_VTOP1] = {0x1, 0x6, 5, 0}, | ||
112 | [DVBT_VTOP2] = {0x1, 0xc9, 5, 0}, | ||
113 | [DVBT_VTOP3] = {0x1, 0xca, 5, 0}, | ||
114 | [DVBT_KRF1] = {0x1, 0xcb, 7, 0}, | ||
115 | [DVBT_KRF2] = {0x1, 0x7, 7, 0}, | ||
116 | [DVBT_KRF3] = {0x1, 0xcd, 7, 0}, | ||
117 | [DVBT_KRF4] = {0x1, 0xce, 7, 0}, | ||
118 | [DVBT_EN_GI_PGA] = {0x1, 0xe5, 0, 0}, | ||
119 | [DVBT_THD_LOCK_UP] = {0x1, 0xd9, 8, 0}, | ||
120 | [DVBT_THD_LOCK_DW] = {0x1, 0xdb, 8, 0}, | ||
121 | [DVBT_THD_UP1] = {0x1, 0xdd, 7, 0}, | ||
122 | [DVBT_THD_DW1] = {0x1, 0xde, 7, 0}, | ||
123 | [DVBT_INTER_CNT_LEN] = {0x1, 0xd8, 3, 0}, | ||
124 | [DVBT_GI_PGA_STATE] = {0x1, 0xe6, 3, 3}, | ||
125 | [DVBT_EN_AGC_PGA] = {0x1, 0xd7, 0, 0}, | ||
126 | [DVBT_CKOUTPAR] = {0x1, 0x7b, 5, 5}, | ||
127 | [DVBT_CKOUT_PWR] = {0x1, 0x7b, 6, 6}, | ||
128 | [DVBT_SYNC_DUR] = {0x1, 0x7b, 7, 7}, | ||
129 | [DVBT_ERR_DUR] = {0x1, 0x7c, 0, 0}, | ||
130 | [DVBT_SYNC_LVL] = {0x1, 0x7c, 1, 1}, | ||
131 | [DVBT_ERR_LVL] = {0x1, 0x7c, 2, 2}, | ||
132 | [DVBT_VAL_LVL] = {0x1, 0x7c, 3, 3}, | ||
133 | [DVBT_SERIAL] = {0x1, 0x7c, 4, 4}, | ||
134 | [DVBT_SER_LSB] = {0x1, 0x7c, 5, 5}, | ||
135 | [DVBT_CDIV_PH0] = {0x1, 0x7d, 3, 0}, | ||
136 | [DVBT_CDIV_PH1] = {0x1, 0x7d, 7, 4}, | ||
137 | [DVBT_MPEG_IO_OPT_2_2] = {0x0, 0x6, 7, 7}, | ||
138 | [DVBT_MPEG_IO_OPT_1_0] = {0x0, 0x7, 7, 6}, | ||
139 | [DVBT_CKOUTPAR_PIP] = {0x0, 0xb7, 4, 4}, | ||
140 | [DVBT_CKOUT_PWR_PIP] = {0x0, 0xb7, 3, 3}, | ||
141 | [DVBT_SYNC_LVL_PIP] = {0x0, 0xb7, 2, 2}, | ||
142 | [DVBT_ERR_LVL_PIP] = {0x0, 0xb7, 1, 1}, | ||
143 | [DVBT_VAL_LVL_PIP] = {0x0, 0xb7, 0, 0}, | ||
144 | [DVBT_CKOUTPAR_PID] = {0x0, 0xb9, 4, 4}, | ||
145 | [DVBT_CKOUT_PWR_PID] = {0x0, 0xb9, 3, 3}, | ||
146 | [DVBT_SYNC_LVL_PID] = {0x0, 0xb9, 2, 2}, | ||
147 | [DVBT_ERR_LVL_PID] = {0x0, 0xb9, 1, 1}, | ||
148 | [DVBT_VAL_LVL_PID] = {0x0, 0xb9, 0, 0}, | ||
149 | [DVBT_SM_PASS] = {0x1, 0x93, 11, 0}, | ||
150 | [DVBT_AD7_SETTING] = {0x0, 0x11, 15, 0}, | ||
151 | [DVBT_RSSI_R] = {0x3, 0x1, 6, 0}, | ||
152 | [DVBT_ACI_DET_IND] = {0x3, 0x12, 0, 0}, | ||
153 | [DVBT_REG_MON] = {0x0, 0xd, 1, 0}, | ||
154 | [DVBT_REG_MONSEL] = {0x0, 0xd, 2, 2}, | ||
155 | [DVBT_REG_GPE] = {0x0, 0xd, 7, 7}, | ||
156 | [DVBT_REG_GPO] = {0x0, 0x10, 0, 0}, | ||
157 | [DVBT_REG_4MSEL] = {0x0, 0x13, 0, 0}, | ||
158 | }; | ||
159 | |||
160 | /* write multiple hardware registers */ | ||
161 | static int rtl2832_wr(struct rtl2832_priv *priv, u8 reg, u8 *val, int len) | ||
162 | { | ||
163 | int ret; | ||
164 | u8 buf[1+len]; | ||
165 | struct i2c_msg msg[1] = { | ||
166 | { | ||
167 | .addr = priv->cfg.i2c_addr, | ||
168 | .flags = 0, | ||
169 | .len = 1+len, | ||
170 | .buf = buf, | ||
171 | } | ||
172 | }; | ||
173 | |||
174 | buf[0] = reg; | ||
175 | memcpy(&buf[1], val, len); | ||
176 | |||
177 | ret = i2c_transfer(priv->i2c, msg, 1); | ||
178 | if (ret == 1) { | ||
179 | ret = 0; | ||
180 | } else { | ||
181 | warn("i2c wr failed=%d reg=%02x len=%d", ret, reg, len); | ||
182 | ret = -EREMOTEIO; | ||
183 | } | ||
184 | return ret; | ||
185 | } | ||
186 | |||
187 | /* read multiple hardware registers */ | ||
188 | static int rtl2832_rd(struct rtl2832_priv *priv, u8 reg, u8 *val, int len) | ||
189 | { | ||
190 | int ret; | ||
191 | struct i2c_msg msg[2] = { | ||
192 | { | ||
193 | .addr = priv->cfg.i2c_addr, | ||
194 | .flags = 0, | ||
195 | .len = 1, | ||
196 | .buf = ®, | ||
197 | }, { | ||
198 | .addr = priv->cfg.i2c_addr, | ||
199 | .flags = I2C_M_RD, | ||
200 | .len = len, | ||
201 | .buf = val, | ||
202 | } | ||
203 | }; | ||
204 | |||
205 | ret = i2c_transfer(priv->i2c, msg, 2); | ||
206 | if (ret == 2) { | ||
207 | ret = 0; | ||
208 | } else { | ||
209 | warn("i2c rd failed=%d reg=%02x len=%d", ret, reg, len); | ||
210 | ret = -EREMOTEIO; | ||
211 | } | ||
212 | return ret; | ||
213 | } | ||
214 | |||
215 | /* write multiple registers */ | ||
216 | static int rtl2832_wr_regs(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val, | ||
217 | int len) | ||
218 | { | ||
219 | int ret; | ||
220 | |||
221 | |||
222 | /* switch bank if needed */ | ||
223 | if (page != priv->page) { | ||
224 | ret = rtl2832_wr(priv, 0x00, &page, 1); | ||
225 | if (ret) | ||
226 | return ret; | ||
227 | |||
228 | priv->page = page; | ||
229 | } | ||
230 | |||
231 | return rtl2832_wr(priv, reg, val, len); | ||
232 | } | ||
233 | |||
234 | /* read multiple registers */ | ||
235 | static int rtl2832_rd_regs(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val, | ||
236 | int len) | ||
237 | { | ||
238 | int ret; | ||
239 | |||
240 | /* switch bank if needed */ | ||
241 | if (page != priv->page) { | ||
242 | ret = rtl2832_wr(priv, 0x00, &page, 1); | ||
243 | if (ret) | ||
244 | return ret; | ||
245 | |||
246 | priv->page = page; | ||
247 | } | ||
248 | |||
249 | return rtl2832_rd(priv, reg, val, len); | ||
250 | } | ||
251 | |||
252 | #if 0 /* currently not used */ | ||
253 | /* write single register */ | ||
254 | static int rtl2832_wr_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 val) | ||
255 | { | ||
256 | return rtl2832_wr_regs(priv, reg, page, &val, 1); | ||
257 | } | ||
258 | #endif | ||
259 | |||
260 | /* read single register */ | ||
261 | static int rtl2832_rd_reg(struct rtl2832_priv *priv, u8 reg, u8 page, u8 *val) | ||
262 | { | ||
263 | return rtl2832_rd_regs(priv, reg, page, val, 1); | ||
264 | } | ||
265 | |||
266 | int rtl2832_rd_demod_reg(struct rtl2832_priv *priv, int reg, u32 *val) | ||
267 | { | ||
268 | int ret; | ||
269 | |||
270 | u8 reg_start_addr; | ||
271 | u8 msb, lsb; | ||
272 | u8 page; | ||
273 | u8 reading[4]; | ||
274 | u32 reading_tmp; | ||
275 | int i; | ||
276 | |||
277 | u8 len; | ||
278 | u32 mask; | ||
279 | |||
280 | reg_start_addr = registers[reg].start_address; | ||
281 | msb = registers[reg].msb; | ||
282 | lsb = registers[reg].lsb; | ||
283 | page = registers[reg].page; | ||
284 | |||
285 | len = (msb >> 3) + 1; | ||
286 | mask = REG_MASK(msb - lsb); | ||
287 | |||
288 | ret = rtl2832_rd_regs(priv, reg_start_addr, page, &reading[0], len); | ||
289 | if (ret) | ||
290 | goto err; | ||
291 | |||
292 | reading_tmp = 0; | ||
293 | for (i = 0; i < len; i++) | ||
294 | reading_tmp |= reading[i] << ((len - 1 - i) * 8); | ||
295 | |||
296 | *val = (reading_tmp >> lsb) & mask; | ||
297 | |||
298 | return ret; | ||
299 | |||
300 | err: | ||
301 | dbg("%s: failed=%d", __func__, ret); | ||
302 | return ret; | ||
303 | |||
304 | } | ||
305 | |||
306 | int rtl2832_wr_demod_reg(struct rtl2832_priv *priv, int reg, u32 val) | ||
307 | { | ||
308 | int ret, i; | ||
309 | u8 len; | ||
310 | u8 reg_start_addr; | ||
311 | u8 msb, lsb; | ||
312 | u8 page; | ||
313 | u32 mask; | ||
314 | |||
315 | |||
316 | u8 reading[4]; | ||
317 | u8 writing[4]; | ||
318 | u32 reading_tmp; | ||
319 | u32 writing_tmp; | ||
320 | |||
321 | |||
322 | reg_start_addr = registers[reg].start_address; | ||
323 | msb = registers[reg].msb; | ||
324 | lsb = registers[reg].lsb; | ||
325 | page = registers[reg].page; | ||
326 | |||
327 | len = (msb >> 3) + 1; | ||
328 | mask = REG_MASK(msb - lsb); | ||
329 | |||
330 | |||
331 | ret = rtl2832_rd_regs(priv, reg_start_addr, page, &reading[0], len); | ||
332 | if (ret) | ||
333 | goto err; | ||
334 | |||
335 | reading_tmp = 0; | ||
336 | for (i = 0; i < len; i++) | ||
337 | reading_tmp |= reading[i] << ((len - 1 - i) * 8); | ||
338 | |||
339 | writing_tmp = reading_tmp & ~(mask << lsb); | ||
340 | writing_tmp |= ((val & mask) << lsb); | ||
341 | |||
342 | |||
343 | for (i = 0; i < len; i++) | ||
344 | writing[i] = (writing_tmp >> ((len - 1 - i) * 8)) & 0xff; | ||
345 | |||
346 | ret = rtl2832_wr_regs(priv, reg_start_addr, page, &writing[0], len); | ||
347 | if (ret) | ||
348 | goto err; | ||
349 | |||
350 | return ret; | ||
351 | |||
352 | err: | ||
353 | dbg("%s: failed=%d", __func__, ret); | ||
354 | return ret; | ||
355 | |||
356 | } | ||
357 | |||
358 | |||
359 | static int rtl2832_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | ||
360 | { | ||
361 | int ret; | ||
362 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
363 | |||
364 | dbg("%s: enable=%d", __func__, enable); | ||
365 | |||
366 | /* gate already open or close */ | ||
367 | if (priv->i2c_gate_state == enable) | ||
368 | return 0; | ||
369 | |||
370 | ret = rtl2832_wr_demod_reg(priv, DVBT_IIC_REPEAT, (enable ? 0x1 : 0x0)); | ||
371 | if (ret) | ||
372 | goto err; | ||
373 | |||
374 | priv->i2c_gate_state = enable; | ||
375 | |||
376 | return ret; | ||
377 | err: | ||
378 | dbg("%s: failed=%d", __func__, ret); | ||
379 | return ret; | ||
380 | } | ||
381 | |||
382 | |||
383 | |||
384 | static int rtl2832_init(struct dvb_frontend *fe) | ||
385 | { | ||
386 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
387 | int i, ret; | ||
388 | |||
389 | u8 en_bbin; | ||
390 | u64 pset_iffreq; | ||
391 | |||
392 | /* initialization values for the demodulator registers */ | ||
393 | struct rtl2832_reg_value rtl2832_initial_regs[] = { | ||
394 | {DVBT_AD_EN_REG, 0x1}, | ||
395 | {DVBT_AD_EN_REG1, 0x1}, | ||
396 | {DVBT_RSD_BER_FAIL_VAL, 0x2800}, | ||
397 | {DVBT_MGD_THD0, 0x10}, | ||
398 | {DVBT_MGD_THD1, 0x20}, | ||
399 | {DVBT_MGD_THD2, 0x20}, | ||
400 | {DVBT_MGD_THD3, 0x40}, | ||
401 | {DVBT_MGD_THD4, 0x22}, | ||
402 | {DVBT_MGD_THD5, 0x32}, | ||
403 | {DVBT_MGD_THD6, 0x37}, | ||
404 | {DVBT_MGD_THD7, 0x39}, | ||
405 | {DVBT_EN_BK_TRK, 0x0}, | ||
406 | {DVBT_EN_CACQ_NOTCH, 0x0}, | ||
407 | {DVBT_AD_AV_REF, 0x2a}, | ||
408 | {DVBT_REG_PI, 0x6}, | ||
409 | {DVBT_PIP_ON, 0x0}, | ||
410 | {DVBT_CDIV_PH0, 0x8}, | ||
411 | {DVBT_CDIV_PH1, 0x8}, | ||
412 | {DVBT_SCALE1_B92, 0x4}, | ||
413 | {DVBT_SCALE1_B93, 0xb0}, | ||
414 | {DVBT_SCALE1_BA7, 0x78}, | ||
415 | {DVBT_SCALE1_BA9, 0x28}, | ||
416 | {DVBT_SCALE1_BAA, 0x59}, | ||
417 | {DVBT_SCALE1_BAB, 0x83}, | ||
418 | {DVBT_SCALE1_BAC, 0xd4}, | ||
419 | {DVBT_SCALE1_BB0, 0x65}, | ||
420 | {DVBT_SCALE1_BB1, 0x43}, | ||
421 | {DVBT_KB_P1, 0x1}, | ||
422 | {DVBT_KB_P2, 0x4}, | ||
423 | {DVBT_KB_P3, 0x7}, | ||
424 | {DVBT_K1_CR_STEP12, 0xa}, | ||
425 | {DVBT_REG_GPE, 0x1}, | ||
426 | {DVBT_SERIAL, 0x0}, | ||
427 | {DVBT_CDIV_PH0, 0x9}, | ||
428 | {DVBT_CDIV_PH1, 0x9}, | ||
429 | {DVBT_MPEG_IO_OPT_2_2, 0x0}, | ||
430 | {DVBT_MPEG_IO_OPT_1_0, 0x0}, | ||
431 | {DVBT_TRK_KS_P2, 0x4}, | ||
432 | {DVBT_TRK_KS_I2, 0x7}, | ||
433 | {DVBT_TR_THD_SET2, 0x6}, | ||
434 | {DVBT_TRK_KC_I2, 0x5}, | ||
435 | {DVBT_CR_THD_SET2, 0x1}, | ||
436 | {DVBT_SPEC_INV, 0x0}, | ||
437 | {DVBT_DAGC_TRG_VAL, 0x5a}, | ||
438 | {DVBT_AGC_TARG_VAL_0, 0x0}, | ||
439 | {DVBT_AGC_TARG_VAL_8_1, 0x5a}, | ||
440 | {DVBT_AAGC_LOOP_GAIN, 0x16}, | ||
441 | {DVBT_LOOP_GAIN2_3_0, 0x6}, | ||
442 | {DVBT_LOOP_GAIN2_4, 0x1}, | ||
443 | {DVBT_LOOP_GAIN3, 0x16}, | ||
444 | {DVBT_VTOP1, 0x35}, | ||
445 | {DVBT_VTOP2, 0x21}, | ||
446 | {DVBT_VTOP3, 0x21}, | ||
447 | {DVBT_KRF1, 0x0}, | ||
448 | {DVBT_KRF2, 0x40}, | ||
449 | {DVBT_KRF3, 0x10}, | ||
450 | {DVBT_KRF4, 0x10}, | ||
451 | {DVBT_IF_AGC_MIN, 0x80}, | ||
452 | {DVBT_IF_AGC_MAX, 0x7f}, | ||
453 | {DVBT_RF_AGC_MIN, 0x80}, | ||
454 | {DVBT_RF_AGC_MAX, 0x7f}, | ||
455 | {DVBT_POLAR_RF_AGC, 0x0}, | ||
456 | {DVBT_POLAR_IF_AGC, 0x0}, | ||
457 | {DVBT_AD7_SETTING, 0xe9bf}, | ||
458 | {DVBT_EN_GI_PGA, 0x0}, | ||
459 | {DVBT_THD_LOCK_UP, 0x0}, | ||
460 | {DVBT_THD_LOCK_DW, 0x0}, | ||
461 | {DVBT_THD_UP1, 0x11}, | ||
462 | {DVBT_THD_DW1, 0xef}, | ||
463 | {DVBT_INTER_CNT_LEN, 0xc}, | ||
464 | {DVBT_GI_PGA_STATE, 0x0}, | ||
465 | {DVBT_EN_AGC_PGA, 0x1}, | ||
466 | {DVBT_IF_AGC_MAN, 0x0}, | ||
467 | }; | ||
468 | |||
469 | |||
470 | dbg("%s", __func__); | ||
471 | |||
472 | en_bbin = (priv->cfg.if_dvbt == 0 ? 0x1 : 0x0); | ||
473 | |||
474 | /* | ||
475 | * PSET_IFFREQ = - floor((IfFreqHz % CrystalFreqHz) * pow(2, 22) | ||
476 | * / CrystalFreqHz) | ||
477 | */ | ||
478 | pset_iffreq = priv->cfg.if_dvbt % priv->cfg.xtal; | ||
479 | pset_iffreq *= 0x400000; | ||
480 | pset_iffreq = div_u64(pset_iffreq, priv->cfg.xtal); | ||
481 | pset_iffreq = pset_iffreq & 0x3fffff; | ||
482 | |||
483 | |||
484 | |||
485 | for (i = 0; i < ARRAY_SIZE(rtl2832_initial_regs); i++) { | ||
486 | ret = rtl2832_wr_demod_reg(priv, rtl2832_initial_regs[i].reg, | ||
487 | rtl2832_initial_regs[i].value); | ||
488 | if (ret) | ||
489 | goto err; | ||
490 | } | ||
491 | |||
492 | /* if frequency settings */ | ||
493 | ret = rtl2832_wr_demod_reg(priv, DVBT_EN_BBIN, en_bbin); | ||
494 | if (ret) | ||
495 | goto err; | ||
496 | |||
497 | ret = rtl2832_wr_demod_reg(priv, DVBT_PSET_IFFREQ, pset_iffreq); | ||
498 | if (ret) | ||
499 | goto err; | ||
500 | |||
501 | priv->sleeping = false; | ||
502 | |||
503 | return ret; | ||
504 | |||
505 | err: | ||
506 | dbg("%s: failed=%d", __func__, ret); | ||
507 | return ret; | ||
508 | } | ||
509 | |||
510 | static int rtl2832_sleep(struct dvb_frontend *fe) | ||
511 | { | ||
512 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
513 | |||
514 | dbg("%s", __func__); | ||
515 | priv->sleeping = true; | ||
516 | return 0; | ||
517 | } | ||
518 | |||
519 | int rtl2832_get_tune_settings(struct dvb_frontend *fe, | ||
520 | struct dvb_frontend_tune_settings *s) | ||
521 | { | ||
522 | dbg("%s", __func__); | ||
523 | s->min_delay_ms = 1000; | ||
524 | s->step_size = fe->ops.info.frequency_stepsize * 2; | ||
525 | s->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1; | ||
526 | return 0; | ||
527 | } | ||
528 | |||
529 | static int rtl2832_set_frontend(struct dvb_frontend *fe) | ||
530 | { | ||
531 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
532 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
533 | int ret, i, j; | ||
534 | u64 bw_mode, num, num2; | ||
535 | u32 resamp_ratio, cfreq_off_ratio; | ||
536 | |||
537 | |||
538 | static u8 bw_params[3][32] = { | ||
539 | /* 6 MHz bandwidth */ | ||
540 | { | ||
541 | 0xf5, 0xff, 0x15, 0x38, 0x5d, 0x6d, 0x52, 0x07, 0xfa, 0x2f, | ||
542 | 0x53, 0xf5, 0x3f, 0xca, 0x0b, 0x91, 0xea, 0x30, 0x63, 0xb2, | ||
543 | 0x13, 0xda, 0x0b, 0xc4, 0x18, 0x7e, 0x16, 0x66, 0x08, 0x67, | ||
544 | 0x19, 0xe0, | ||
545 | }, | ||
546 | |||
547 | /* 7 MHz bandwidth */ | ||
548 | { | ||
549 | 0xe7, 0xcc, 0xb5, 0xba, 0xe8, 0x2f, 0x67, 0x61, 0x00, 0xaf, | ||
550 | 0x86, 0xf2, 0xbf, 0x59, 0x04, 0x11, 0xb6, 0x33, 0xa4, 0x30, | ||
551 | 0x15, 0x10, 0x0a, 0x42, 0x18, 0xf8, 0x17, 0xd9, 0x07, 0x22, | ||
552 | 0x19, 0x10, | ||
553 | }, | ||
554 | |||
555 | /* 8 MHz bandwidth */ | ||
556 | { | ||
557 | 0x09, 0xf6, 0xd2, 0xa7, 0x9a, 0xc9, 0x27, 0x77, 0x06, 0xbf, | ||
558 | 0xec, 0xf4, 0x4f, 0x0b, 0xfc, 0x01, 0x63, 0x35, 0x54, 0xa7, | ||
559 | 0x16, 0x66, 0x08, 0xb4, 0x19, 0x6e, 0x19, 0x65, 0x05, 0xc8, | ||
560 | 0x19, 0xe0, | ||
561 | }, | ||
562 | }; | ||
563 | |||
564 | |||
565 | dbg("%s: frequency=%d bandwidth_hz=%d inversion=%d", __func__, | ||
566 | c->frequency, c->bandwidth_hz, c->inversion); | ||
567 | |||
568 | |||
569 | /* program tuner */ | ||
570 | if (fe->ops.tuner_ops.set_params) | ||
571 | fe->ops.tuner_ops.set_params(fe); | ||
572 | |||
573 | |||
574 | switch (c->bandwidth_hz) { | ||
575 | case 6000000: | ||
576 | i = 0; | ||
577 | bw_mode = 48000000; | ||
578 | break; | ||
579 | case 7000000: | ||
580 | i = 1; | ||
581 | bw_mode = 56000000; | ||
582 | break; | ||
583 | case 8000000: | ||
584 | i = 2; | ||
585 | bw_mode = 64000000; | ||
586 | break; | ||
587 | default: | ||
588 | dbg("invalid bandwidth"); | ||
589 | return -EINVAL; | ||
590 | } | ||
591 | |||
592 | for (j = 0; j < sizeof(bw_params[j]); j++) { | ||
593 | ret = rtl2832_wr_regs(priv, 0x1c+j, 1, &bw_params[i][j], 1); | ||
594 | if (ret) | ||
595 | goto err; | ||
596 | } | ||
597 | |||
598 | /* calculate and set resample ratio | ||
599 | * RSAMP_RATIO = floor(CrystalFreqHz * 7 * pow(2, 22) | ||
600 | * / ConstWithBandwidthMode) | ||
601 | */ | ||
602 | num = priv->cfg.xtal * 7; | ||
603 | num *= 0x400000; | ||
604 | num = div_u64(num, bw_mode); | ||
605 | resamp_ratio = num & 0x3ffffff; | ||
606 | ret = rtl2832_wr_demod_reg(priv, DVBT_RSAMP_RATIO, resamp_ratio); | ||
607 | if (ret) | ||
608 | goto err; | ||
609 | |||
610 | /* calculate and set cfreq off ratio | ||
611 | * CFREQ_OFF_RATIO = - floor(ConstWithBandwidthMode * pow(2, 20) | ||
612 | * / (CrystalFreqHz * 7)) | ||
613 | */ | ||
614 | num = bw_mode << 20; | ||
615 | num2 = priv->cfg.xtal * 7; | ||
616 | num = div_u64(num, num2); | ||
617 | num = -num; | ||
618 | cfreq_off_ratio = num & 0xfffff; | ||
619 | ret = rtl2832_wr_demod_reg(priv, DVBT_CFREQ_OFF_RATIO, cfreq_off_ratio); | ||
620 | if (ret) | ||
621 | goto err; | ||
622 | |||
623 | |||
624 | /* soft reset */ | ||
625 | ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x1); | ||
626 | if (ret) | ||
627 | goto err; | ||
628 | |||
629 | ret = rtl2832_wr_demod_reg(priv, DVBT_SOFT_RST, 0x0); | ||
630 | if (ret) | ||
631 | goto err; | ||
632 | |||
633 | return ret; | ||
634 | err: | ||
635 | info("%s: failed=%d", __func__, ret); | ||
636 | return ret; | ||
637 | } | ||
638 | |||
639 | static int rtl2832_read_status(struct dvb_frontend *fe, fe_status_t *status) | ||
640 | { | ||
641 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
642 | int ret; | ||
643 | u32 tmp; | ||
644 | *status = 0; | ||
645 | |||
646 | |||
647 | dbg("%s", __func__); | ||
648 | if (priv->sleeping) | ||
649 | return 0; | ||
650 | |||
651 | ret = rtl2832_rd_demod_reg(priv, DVBT_FSM_STAGE, &tmp); | ||
652 | if (ret) | ||
653 | goto err; | ||
654 | |||
655 | if (tmp == 11) { | ||
656 | *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | | ||
657 | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK; | ||
658 | } | ||
659 | /* TODO find out if this is also true for rtl2832? */ | ||
660 | /*else if (tmp == 10) { | ||
661 | *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | | ||
662 | FE_HAS_VITERBI; | ||
663 | }*/ | ||
664 | |||
665 | return ret; | ||
666 | err: | ||
667 | info("%s: failed=%d", __func__, ret); | ||
668 | return ret; | ||
669 | } | ||
670 | |||
671 | static int rtl2832_read_snr(struct dvb_frontend *fe, u16 *snr) | ||
672 | { | ||
673 | *snr = 0; | ||
674 | return 0; | ||
675 | } | ||
676 | |||
677 | static int rtl2832_read_ber(struct dvb_frontend *fe, u32 *ber) | ||
678 | { | ||
679 | *ber = 0; | ||
680 | return 0; | ||
681 | } | ||
682 | |||
683 | static int rtl2832_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | ||
684 | { | ||
685 | *ucblocks = 0; | ||
686 | return 0; | ||
687 | } | ||
688 | |||
689 | |||
690 | static int rtl2832_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | ||
691 | { | ||
692 | *strength = 0; | ||
693 | return 0; | ||
694 | } | ||
695 | |||
696 | static struct dvb_frontend_ops rtl2832_ops; | ||
697 | |||
698 | static void rtl2832_release(struct dvb_frontend *fe) | ||
699 | { | ||
700 | struct rtl2832_priv *priv = fe->demodulator_priv; | ||
701 | |||
702 | dbg("%s", __func__); | ||
703 | kfree(priv); | ||
704 | } | ||
705 | |||
706 | struct dvb_frontend *rtl2832_attach(const struct rtl2832_config *cfg, | ||
707 | struct i2c_adapter *i2c) | ||
708 | { | ||
709 | struct rtl2832_priv *priv = NULL; | ||
710 | int ret = 0; | ||
711 | u8 tmp; | ||
712 | |||
713 | dbg("%s", __func__); | ||
714 | |||
715 | /* allocate memory for the internal state */ | ||
716 | priv = kzalloc(sizeof(struct rtl2832_priv), GFP_KERNEL); | ||
717 | if (priv == NULL) | ||
718 | goto err; | ||
719 | |||
720 | /* setup the priv */ | ||
721 | priv->i2c = i2c; | ||
722 | priv->tuner = cfg->tuner; | ||
723 | memcpy(&priv->cfg, cfg, sizeof(struct rtl2832_config)); | ||
724 | |||
725 | /* check if the demod is there */ | ||
726 | ret = rtl2832_rd_reg(priv, 0x00, 0x0, &tmp); | ||
727 | if (ret) | ||
728 | goto err; | ||
729 | |||
730 | /* create dvb_frontend */ | ||
731 | memcpy(&priv->fe.ops, &rtl2832_ops, sizeof(struct dvb_frontend_ops)); | ||
732 | priv->fe.demodulator_priv = priv; | ||
733 | |||
734 | /* TODO implement sleep mode */ | ||
735 | priv->sleeping = true; | ||
736 | |||
737 | return &priv->fe; | ||
738 | err: | ||
739 | dbg("%s: failed=%d", __func__, ret); | ||
740 | kfree(priv); | ||
741 | return NULL; | ||
742 | } | ||
743 | EXPORT_SYMBOL(rtl2832_attach); | ||
744 | |||
745 | static struct dvb_frontend_ops rtl2832_ops = { | ||
746 | .delsys = { SYS_DVBT }, | ||
747 | .info = { | ||
748 | .name = "Realtek RTL2832 (DVB-T)", | ||
749 | .frequency_min = 174000000, | ||
750 | .frequency_max = 862000000, | ||
751 | .frequency_stepsize = 166667, | ||
752 | .caps = FE_CAN_FEC_1_2 | | ||
753 | FE_CAN_FEC_2_3 | | ||
754 | FE_CAN_FEC_3_4 | | ||
755 | FE_CAN_FEC_5_6 | | ||
756 | FE_CAN_FEC_7_8 | | ||
757 | FE_CAN_FEC_AUTO | | ||
758 | FE_CAN_QPSK | | ||
759 | FE_CAN_QAM_16 | | ||
760 | FE_CAN_QAM_64 | | ||
761 | FE_CAN_QAM_AUTO | | ||
762 | FE_CAN_TRANSMISSION_MODE_AUTO | | ||
763 | FE_CAN_GUARD_INTERVAL_AUTO | | ||
764 | FE_CAN_HIERARCHY_AUTO | | ||
765 | FE_CAN_RECOVER | | ||
766 | FE_CAN_MUTE_TS | ||
767 | }, | ||
768 | |||
769 | .release = rtl2832_release, | ||
770 | |||
771 | .init = rtl2832_init, | ||
772 | .sleep = rtl2832_sleep, | ||
773 | |||
774 | .get_tune_settings = rtl2832_get_tune_settings, | ||
775 | |||
776 | .set_frontend = rtl2832_set_frontend, | ||
777 | |||
778 | .read_status = rtl2832_read_status, | ||
779 | .read_snr = rtl2832_read_snr, | ||
780 | .read_ber = rtl2832_read_ber, | ||
781 | .read_ucblocks = rtl2832_read_ucblocks, | ||
782 | .read_signal_strength = rtl2832_read_signal_strength, | ||
783 | .i2c_gate_ctrl = rtl2832_i2c_gate_ctrl, | ||
784 | }; | ||
785 | |||
786 | MODULE_AUTHOR("Thomas Mair <mair.thomas86@gmail.com>"); | ||
787 | MODULE_DESCRIPTION("Realtek RTL2832 DVB-T demodulator driver"); | ||
788 | MODULE_LICENSE("GPL"); | ||
789 | MODULE_VERSION("0.5"); | ||
diff --git a/drivers/media/dvb/frontends/rtl2832.h b/drivers/media/dvb/frontends/rtl2832.h new file mode 100644 index 000000000000..d94dc9a3fa62 --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832.h | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * Realtek RTL2832 DVB-T demodulator driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef RTL2832_H | ||
22 | #define RTL2832_H | ||
23 | |||
24 | #include <linux/dvb/frontend.h> | ||
25 | |||
26 | struct rtl2832_config { | ||
27 | /* | ||
28 | * Demodulator I2C address. | ||
29 | */ | ||
30 | u8 i2c_addr; | ||
31 | |||
32 | /* | ||
33 | * Xtal frequency. | ||
34 | * Hz | ||
35 | * 4000000, 16000000, 25000000, 28800000 | ||
36 | */ | ||
37 | u32 xtal; | ||
38 | |||
39 | /* | ||
40 | * IFs for all used modes. | ||
41 | * Hz | ||
42 | * 4570000, 4571429, 36000000, 36125000, 36166667, 44000000 | ||
43 | */ | ||
44 | u32 if_dvbt; | ||
45 | |||
46 | /* | ||
47 | */ | ||
48 | u8 tuner; | ||
49 | }; | ||
50 | |||
51 | |||
52 | #if defined(CONFIG_DVB_RTL2832) || \ | ||
53 | (defined(CONFIG_DVB_RTL2832_MODULE) && defined(MODULE)) | ||
54 | extern struct dvb_frontend *rtl2832_attach( | ||
55 | const struct rtl2832_config *cfg, | ||
56 | struct i2c_adapter *i2c | ||
57 | ); | ||
58 | |||
59 | extern struct i2c_adapter *rtl2832_get_tuner_i2c_adapter( | ||
60 | struct dvb_frontend *fe | ||
61 | ); | ||
62 | #else | ||
63 | static inline struct dvb_frontend *rtl2832_attach( | ||
64 | const struct rtl2832_config *config, | ||
65 | struct i2c_adapter *i2c | ||
66 | ) | ||
67 | { | ||
68 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
69 | return NULL; | ||
70 | } | ||
71 | #endif | ||
72 | |||
73 | |||
74 | #endif /* RTL2832_H */ | ||
diff --git a/drivers/media/dvb/frontends/rtl2832_priv.h b/drivers/media/dvb/frontends/rtl2832_priv.h new file mode 100644 index 000000000000..0ce9502da8ba --- /dev/null +++ b/drivers/media/dvb/frontends/rtl2832_priv.h | |||
@@ -0,0 +1,260 @@ | |||
1 | /* | ||
2 | * Realtek RTL2832 DVB-T demodulator driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Thomas Mair <thomas.mair86@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef RTL2832_PRIV_H | ||
22 | #define RTL2832_PRIV_H | ||
23 | |||
24 | #include "dvb_frontend.h" | ||
25 | #include "rtl2832.h" | ||
26 | |||
27 | #define LOG_PREFIX "rtl2832" | ||
28 | |||
29 | #undef dbg | ||
30 | #define dbg(f, arg...) \ | ||
31 | do { \ | ||
32 | if (rtl2832_debug) \ | ||
33 | printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg); \ | ||
34 | } while (0) | ||
35 | #undef err | ||
36 | #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) | ||
37 | #undef info | ||
38 | #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
39 | #undef warn | ||
40 | #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg) | ||
41 | |||
42 | struct rtl2832_priv { | ||
43 | struct i2c_adapter *i2c; | ||
44 | struct dvb_frontend fe; | ||
45 | struct rtl2832_config cfg; | ||
46 | |||
47 | bool i2c_gate_state; | ||
48 | bool sleeping; | ||
49 | |||
50 | u8 tuner; | ||
51 | u8 page; /* active register page */ | ||
52 | }; | ||
53 | |||
54 | struct rtl2832_reg_entry { | ||
55 | u8 page; | ||
56 | u8 start_address; | ||
57 | u8 msb; | ||
58 | u8 lsb; | ||
59 | }; | ||
60 | |||
61 | struct rtl2832_reg_value { | ||
62 | int reg; | ||
63 | u32 value; | ||
64 | }; | ||
65 | |||
66 | |||
67 | /* Demod register bit names */ | ||
68 | enum DVBT_REG_BIT_NAME { | ||
69 | DVBT_SOFT_RST, | ||
70 | DVBT_IIC_REPEAT, | ||
71 | DVBT_TR_WAIT_MIN_8K, | ||
72 | DVBT_RSD_BER_FAIL_VAL, | ||
73 | DVBT_EN_BK_TRK, | ||
74 | DVBT_REG_PI, | ||
75 | DVBT_REG_PFREQ_1_0, | ||
76 | DVBT_PD_DA8, | ||
77 | DVBT_LOCK_TH, | ||
78 | DVBT_BER_PASS_SCAL, | ||
79 | DVBT_CE_FFSM_BYPASS, | ||
80 | DVBT_ALPHAIIR_N, | ||
81 | DVBT_ALPHAIIR_DIF, | ||
82 | DVBT_EN_TRK_SPAN, | ||
83 | DVBT_LOCK_TH_LEN, | ||
84 | DVBT_CCI_THRE, | ||
85 | DVBT_CCI_MON_SCAL, | ||
86 | DVBT_CCI_M0, | ||
87 | DVBT_CCI_M1, | ||
88 | DVBT_CCI_M2, | ||
89 | DVBT_CCI_M3, | ||
90 | DVBT_SPEC_INIT_0, | ||
91 | DVBT_SPEC_INIT_1, | ||
92 | DVBT_SPEC_INIT_2, | ||
93 | DVBT_AD_EN_REG, | ||
94 | DVBT_AD_EN_REG1, | ||
95 | DVBT_EN_BBIN, | ||
96 | DVBT_MGD_THD0, | ||
97 | DVBT_MGD_THD1, | ||
98 | DVBT_MGD_THD2, | ||
99 | DVBT_MGD_THD3, | ||
100 | DVBT_MGD_THD4, | ||
101 | DVBT_MGD_THD5, | ||
102 | DVBT_MGD_THD6, | ||
103 | DVBT_MGD_THD7, | ||
104 | DVBT_EN_CACQ_NOTCH, | ||
105 | DVBT_AD_AV_REF, | ||
106 | DVBT_PIP_ON, | ||
107 | DVBT_SCALE1_B92, | ||
108 | DVBT_SCALE1_B93, | ||
109 | DVBT_SCALE1_BA7, | ||
110 | DVBT_SCALE1_BA9, | ||
111 | DVBT_SCALE1_BAA, | ||
112 | DVBT_SCALE1_BAB, | ||
113 | DVBT_SCALE1_BAC, | ||
114 | DVBT_SCALE1_BB0, | ||
115 | DVBT_SCALE1_BB1, | ||
116 | DVBT_KB_P1, | ||
117 | DVBT_KB_P2, | ||
118 | DVBT_KB_P3, | ||
119 | DVBT_OPT_ADC_IQ, | ||
120 | DVBT_AD_AVI, | ||
121 | DVBT_AD_AVQ, | ||
122 | DVBT_K1_CR_STEP12, | ||
123 | DVBT_TRK_KS_P2, | ||
124 | DVBT_TRK_KS_I2, | ||
125 | DVBT_TR_THD_SET2, | ||
126 | DVBT_TRK_KC_P2, | ||
127 | DVBT_TRK_KC_I2, | ||
128 | DVBT_CR_THD_SET2, | ||
129 | DVBT_PSET_IFFREQ, | ||
130 | DVBT_SPEC_INV, | ||
131 | DVBT_BW_INDEX, | ||
132 | DVBT_RSAMP_RATIO, | ||
133 | DVBT_CFREQ_OFF_RATIO, | ||
134 | DVBT_FSM_STAGE, | ||
135 | DVBT_RX_CONSTEL, | ||
136 | DVBT_RX_HIER, | ||
137 | DVBT_RX_C_RATE_LP, | ||
138 | DVBT_RX_C_RATE_HP, | ||
139 | DVBT_GI_IDX, | ||
140 | DVBT_FFT_MODE_IDX, | ||
141 | DVBT_RSD_BER_EST, | ||
142 | DVBT_CE_EST_EVM, | ||
143 | DVBT_RF_AGC_VAL, | ||
144 | DVBT_IF_AGC_VAL, | ||
145 | DVBT_DAGC_VAL, | ||
146 | DVBT_SFREQ_OFF, | ||
147 | DVBT_CFREQ_OFF, | ||
148 | DVBT_POLAR_RF_AGC, | ||
149 | DVBT_POLAR_IF_AGC, | ||
150 | DVBT_AAGC_HOLD, | ||
151 | DVBT_EN_RF_AGC, | ||
152 | DVBT_EN_IF_AGC, | ||
153 | DVBT_IF_AGC_MIN, | ||
154 | DVBT_IF_AGC_MAX, | ||
155 | DVBT_RF_AGC_MIN, | ||
156 | DVBT_RF_AGC_MAX, | ||
157 | DVBT_IF_AGC_MAN, | ||
158 | DVBT_IF_AGC_MAN_VAL, | ||
159 | DVBT_RF_AGC_MAN, | ||
160 | DVBT_RF_AGC_MAN_VAL, | ||
161 | DVBT_DAGC_TRG_VAL, | ||
162 | DVBT_AGC_TARG_VAL, | ||
163 | DVBT_LOOP_GAIN_3_0, | ||
164 | DVBT_LOOP_GAIN_4, | ||
165 | DVBT_VTOP, | ||
166 | DVBT_KRF, | ||
167 | DVBT_AGC_TARG_VAL_0, | ||
168 | DVBT_AGC_TARG_VAL_8_1, | ||
169 | DVBT_AAGC_LOOP_GAIN, | ||
170 | DVBT_LOOP_GAIN2_3_0, | ||
171 | DVBT_LOOP_GAIN2_4, | ||
172 | DVBT_LOOP_GAIN3, | ||
173 | DVBT_VTOP1, | ||
174 | DVBT_VTOP2, | ||
175 | DVBT_VTOP3, | ||
176 | DVBT_KRF1, | ||
177 | DVBT_KRF2, | ||
178 | DVBT_KRF3, | ||
179 | DVBT_KRF4, | ||
180 | DVBT_EN_GI_PGA, | ||
181 | DVBT_THD_LOCK_UP, | ||
182 | DVBT_THD_LOCK_DW, | ||
183 | DVBT_THD_UP1, | ||
184 | DVBT_THD_DW1, | ||
185 | DVBT_INTER_CNT_LEN, | ||
186 | DVBT_GI_PGA_STATE, | ||
187 | DVBT_EN_AGC_PGA, | ||
188 | DVBT_CKOUTPAR, | ||
189 | DVBT_CKOUT_PWR, | ||
190 | DVBT_SYNC_DUR, | ||
191 | DVBT_ERR_DUR, | ||
192 | DVBT_SYNC_LVL, | ||
193 | DVBT_ERR_LVL, | ||
194 | DVBT_VAL_LVL, | ||
195 | DVBT_SERIAL, | ||
196 | DVBT_SER_LSB, | ||
197 | DVBT_CDIV_PH0, | ||
198 | DVBT_CDIV_PH1, | ||
199 | DVBT_MPEG_IO_OPT_2_2, | ||
200 | DVBT_MPEG_IO_OPT_1_0, | ||
201 | DVBT_CKOUTPAR_PIP, | ||
202 | DVBT_CKOUT_PWR_PIP, | ||
203 | DVBT_SYNC_LVL_PIP, | ||
204 | DVBT_ERR_LVL_PIP, | ||
205 | DVBT_VAL_LVL_PIP, | ||
206 | DVBT_CKOUTPAR_PID, | ||
207 | DVBT_CKOUT_PWR_PID, | ||
208 | DVBT_SYNC_LVL_PID, | ||
209 | DVBT_ERR_LVL_PID, | ||
210 | DVBT_VAL_LVL_PID, | ||
211 | DVBT_SM_PASS, | ||
212 | DVBT_UPDATE_REG_2, | ||
213 | DVBT_BTHD_P3, | ||
214 | DVBT_BTHD_D3, | ||
215 | DVBT_FUNC4_REG0, | ||
216 | DVBT_FUNC4_REG1, | ||
217 | DVBT_FUNC4_REG2, | ||
218 | DVBT_FUNC4_REG3, | ||
219 | DVBT_FUNC4_REG4, | ||
220 | DVBT_FUNC4_REG5, | ||
221 | DVBT_FUNC4_REG6, | ||
222 | DVBT_FUNC4_REG7, | ||
223 | DVBT_FUNC4_REG8, | ||
224 | DVBT_FUNC4_REG9, | ||
225 | DVBT_FUNC4_REG10, | ||
226 | DVBT_FUNC5_REG0, | ||
227 | DVBT_FUNC5_REG1, | ||
228 | DVBT_FUNC5_REG2, | ||
229 | DVBT_FUNC5_REG3, | ||
230 | DVBT_FUNC5_REG4, | ||
231 | DVBT_FUNC5_REG5, | ||
232 | DVBT_FUNC5_REG6, | ||
233 | DVBT_FUNC5_REG7, | ||
234 | DVBT_FUNC5_REG8, | ||
235 | DVBT_FUNC5_REG9, | ||
236 | DVBT_FUNC5_REG10, | ||
237 | DVBT_FUNC5_REG11, | ||
238 | DVBT_FUNC5_REG12, | ||
239 | DVBT_FUNC5_REG13, | ||
240 | DVBT_FUNC5_REG14, | ||
241 | DVBT_FUNC5_REG15, | ||
242 | DVBT_FUNC5_REG16, | ||
243 | DVBT_FUNC5_REG17, | ||
244 | DVBT_FUNC5_REG18, | ||
245 | DVBT_AD7_SETTING, | ||
246 | DVBT_RSSI_R, | ||
247 | DVBT_ACI_DET_IND, | ||
248 | DVBT_REG_MON, | ||
249 | DVBT_REG_MONSEL, | ||
250 | DVBT_REG_GPE, | ||
251 | DVBT_REG_GPO, | ||
252 | DVBT_REG_4MSEL, | ||
253 | DVBT_TEST_REG_1, | ||
254 | DVBT_TEST_REG_2, | ||
255 | DVBT_TEST_REG_3, | ||
256 | DVBT_TEST_REG_4, | ||
257 | DVBT_REG_BIT_NAME_ITEM_TERMINATOR, | ||
258 | }; | ||
259 | |||
260 | #endif /* RTL2832_PRIV_H */ | ||
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 2322257c69ae..e2fec9ebf947 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c | |||
@@ -634,7 +634,6 @@ static int s5h1420_set_frontend(struct dvb_frontend *fe) | |||
634 | struct s5h1420_state* state = fe->demodulator_priv; | 634 | struct s5h1420_state* state = fe->demodulator_priv; |
635 | int frequency_delta; | 635 | int frequency_delta; |
636 | struct dvb_frontend_tune_settings fesettings; | 636 | struct dvb_frontend_tune_settings fesettings; |
637 | uint8_t clock_setting; | ||
638 | 637 | ||
639 | dprintk("enter %s\n", __func__); | 638 | dprintk("enter %s\n", __func__); |
640 | 639 | ||
@@ -679,25 +678,6 @@ static int s5h1420_set_frontend(struct dvb_frontend *fe) | |||
679 | else | 678 | else |
680 | state->fclk = 44000000; | 679 | state->fclk = 44000000; |
681 | 680 | ||
682 | /* Clock */ | ||
683 | switch (state->fclk) { | ||
684 | default: | ||
685 | case 88000000: | ||
686 | clock_setting = 80; | ||
687 | break; | ||
688 | case 86000000: | ||
689 | clock_setting = 78; | ||
690 | break; | ||
691 | case 80000000: | ||
692 | clock_setting = 72; | ||
693 | break; | ||
694 | case 59000000: | ||
695 | clock_setting = 51; | ||
696 | break; | ||
697 | case 44000000: | ||
698 | clock_setting = 36; | ||
699 | break; | ||
700 | } | ||
701 | dprintk("pll01: %d, ToneFreq: %d\n", state->fclk/1000000 - 8, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32)); | 681 | dprintk("pll01: %d, ToneFreq: %d\n", state->fclk/1000000 - 8, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32)); |
702 | s5h1420_writereg(state, PLL01, state->fclk/1000000 - 8); | 682 | s5h1420_writereg(state, PLL01, state->fclk/1000000 - 8); |
703 | s5h1420_writereg(state, PLL02, 0x40); | 683 | s5h1420_writereg(state, PLL02, 0x40); |
diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index 8b0dc74a3298..5d7f8a9b451b 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c | |||
@@ -1129,7 +1129,6 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
1129 | struct stb0899_internal *internal = &state->internal; | 1129 | struct stb0899_internal *internal = &state->internal; |
1130 | 1130 | ||
1131 | u8 lsb, msb; | 1131 | u8 lsb, msb; |
1132 | u32 i; | ||
1133 | 1132 | ||
1134 | *ber = 0; | 1133 | *ber = 0; |
1135 | 1134 | ||
@@ -1137,14 +1136,9 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
1137 | case SYS_DVBS: | 1136 | case SYS_DVBS: |
1138 | case SYS_DSS: | 1137 | case SYS_DSS: |
1139 | if (internal->lock) { | 1138 | if (internal->lock) { |
1140 | /* average 5 BER values */ | 1139 | lsb = stb0899_read_reg(state, STB0899_ECNT1L); |
1141 | for (i = 0; i < 5; i++) { | 1140 | msb = stb0899_read_reg(state, STB0899_ECNT1M); |
1142 | msleep(100); | 1141 | *ber = MAKEWORD16(msb, lsb); |
1143 | lsb = stb0899_read_reg(state, STB0899_ECNT1L); | ||
1144 | msb = stb0899_read_reg(state, STB0899_ECNT1M); | ||
1145 | *ber += MAKEWORD16(msb, lsb); | ||
1146 | } | ||
1147 | *ber /= 5; | ||
1148 | /* Viterbi Check */ | 1142 | /* Viterbi Check */ |
1149 | if (STB0899_GETFIELD(VSTATUS_PRFVIT, internal->v_status)) { | 1143 | if (STB0899_GETFIELD(VSTATUS_PRFVIT, internal->v_status)) { |
1150 | /* Error Rate */ | 1144 | /* Error Rate */ |
@@ -1157,13 +1151,9 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
1157 | break; | 1151 | break; |
1158 | case SYS_DVBS2: | 1152 | case SYS_DVBS2: |
1159 | if (internal->lock) { | 1153 | if (internal->lock) { |
1160 | /* Average 5 PER values */ | 1154 | lsb = stb0899_read_reg(state, STB0899_ECNT1L); |
1161 | for (i = 0; i < 5; i++) { | 1155 | msb = stb0899_read_reg(state, STB0899_ECNT1M); |
1162 | msleep(100); | 1156 | *ber = MAKEWORD16(msb, lsb); |
1163 | lsb = stb0899_read_reg(state, STB0899_ECNT1L); | ||
1164 | msb = stb0899_read_reg(state, STB0899_ECNT1M); | ||
1165 | *ber += MAKEWORD16(msb, lsb); | ||
1166 | } | ||
1167 | /* ber = ber * 10 ^ 7 */ | 1157 | /* ber = ber * 10 ^ 7 */ |
1168 | *ber *= 10000000; | 1158 | *ber *= 10000000; |
1169 | *ber /= (-1 + (1 << (4 + 2 * STB0899_GETFIELD(NOE, internal->err_ctrl)))); | 1159 | *ber /= (-1 + (1 << (4 + 2 * STB0899_GETFIELD(NOE, internal->err_ctrl)))); |
diff --git a/drivers/media/dvb/frontends/stv0367.c b/drivers/media/dvb/frontends/stv0367.c index fdd20c7737b5..2a8aaeb1112d 100644 --- a/drivers/media/dvb/frontends/stv0367.c +++ b/drivers/media/dvb/frontends/stv0367.c | |||
@@ -1584,7 +1584,7 @@ static int stv0367ter_algo(struct dvb_frontend *fe) | |||
1584 | struct stv0367ter_state *ter_state = state->ter_state; | 1584 | struct stv0367ter_state *ter_state = state->ter_state; |
1585 | int offset = 0, tempo = 0; | 1585 | int offset = 0, tempo = 0; |
1586 | u8 u_var; | 1586 | u8 u_var; |
1587 | u8 /*constell,*/ counter, tps_rcvd[2]; | 1587 | u8 /*constell,*/ counter; |
1588 | s8 step; | 1588 | s8 step; |
1589 | s32 timing_offset = 0; | 1589 | s32 timing_offset = 0; |
1590 | u32 trl_nomrate = 0, InternalFreq = 0, temp = 0; | 1590 | u32 trl_nomrate = 0, InternalFreq = 0, temp = 0; |
@@ -1709,9 +1709,6 @@ static int stv0367ter_algo(struct dvb_frontend *fe) | |||
1709 | return 0; | 1709 | return 0; |
1710 | 1710 | ||
1711 | ter_state->state = FE_TER_LOCKOK; | 1711 | ter_state->state = FE_TER_LOCKOK; |
1712 | /* update results */ | ||
1713 | tps_rcvd[0] = stv0367_readreg(state, R367TER_TPS_RCVD2); | ||
1714 | tps_rcvd[1] = stv0367_readreg(state, R367TER_TPS_RCVD3); | ||
1715 | 1712 | ||
1716 | ter_state->mode = stv0367_readbits(state, F367TER_SYR_MODE); | 1713 | ter_state->mode = stv0367_readbits(state, F367TER_SYR_MODE); |
1717 | ter_state->guard = stv0367_readbits(state, F367TER_SYR_GUARD); | 1714 | ter_state->guard = stv0367_readbits(state, F367TER_SYR_GUARD); |
diff --git a/drivers/media/dvb/frontends/stv090x.c b/drivers/media/dvb/frontends/stv090x.c index d79e69f65cbb..ea86a5603e57 100644 --- a/drivers/media/dvb/frontends/stv090x.c +++ b/drivers/media/dvb/frontends/stv090x.c | |||
@@ -3172,7 +3172,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3172 | enum stv090x_signal_state signal_state = STV090x_NOCARRIER; | 3172 | enum stv090x_signal_state signal_state = STV090x_NOCARRIER; |
3173 | u32 reg; | 3173 | u32 reg; |
3174 | s32 agc1_power, power_iq = 0, i; | 3174 | s32 agc1_power, power_iq = 0, i; |
3175 | int lock = 0, low_sr = 0, no_signal = 0; | 3175 | int lock = 0, low_sr = 0; |
3176 | 3176 | ||
3177 | reg = STV090x_READ_DEMOD(state, TSCFGH); | 3177 | reg = STV090x_READ_DEMOD(state, TSCFGH); |
3178 | STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* Stop path 1 stream merger */ | 3178 | STV090x_SETFIELD_Px(reg, RST_HWARE_FIELD, 1); /* Stop path 1 stream merger */ |
@@ -3413,7 +3413,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state) | |||
3413 | goto err; | 3413 | goto err; |
3414 | } else { | 3414 | } else { |
3415 | signal_state = STV090x_NODATA; | 3415 | signal_state = STV090x_NODATA; |
3416 | no_signal = stv090x_chk_signal(state); | 3416 | stv090x_chk_signal(state); |
3417 | } | 3417 | } |
3418 | } | 3418 | } |
3419 | return signal_state; | 3419 | return signal_state; |
diff --git a/drivers/media/dvb/frontends/tda10071.c b/drivers/media/dvb/frontends/tda10071.c index c21bc92d2811..703c3d05f9f4 100644 --- a/drivers/media/dvb/frontends/tda10071.c +++ b/drivers/media/dvb/frontends/tda10071.c | |||
@@ -20,10 +20,6 @@ | |||
20 | 20 | ||
21 | #include "tda10071_priv.h" | 21 | #include "tda10071_priv.h" |
22 | 22 | ||
23 | int tda10071_debug; | ||
24 | module_param_named(debug, tda10071_debug, int, 0644); | ||
25 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | ||
26 | |||
27 | static struct dvb_frontend_ops tda10071_ops; | 23 | static struct dvb_frontend_ops tda10071_ops; |
28 | 24 | ||
29 | /* write multiple registers */ | 25 | /* write multiple registers */ |
@@ -48,7 +44,8 @@ static int tda10071_wr_regs(struct tda10071_priv *priv, u8 reg, u8 *val, | |||
48 | if (ret == 1) { | 44 | if (ret == 1) { |
49 | ret = 0; | 45 | ret = 0; |
50 | } else { | 46 | } else { |
51 | warn("i2c wr failed=%d reg=%02x len=%d", ret, reg, len); | 47 | dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ |
48 | "len=%d\n", KBUILD_MODNAME, ret, reg, len); | ||
52 | ret = -EREMOTEIO; | 49 | ret = -EREMOTEIO; |
53 | } | 50 | } |
54 | return ret; | 51 | return ret; |
@@ -79,7 +76,8 @@ static int tda10071_rd_regs(struct tda10071_priv *priv, u8 reg, u8 *val, | |||
79 | memcpy(val, buf, len); | 76 | memcpy(val, buf, len); |
80 | ret = 0; | 77 | ret = 0; |
81 | } else { | 78 | } else { |
82 | warn("i2c rd failed=%d reg=%02x len=%d", ret, reg, len); | 79 | dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ |
80 | "len=%d\n", KBUILD_MODNAME, ret, reg, len); | ||
83 | ret = -EREMOTEIO; | 81 | ret = -EREMOTEIO; |
84 | } | 82 | } |
85 | return ret; | 83 | return ret; |
@@ -170,7 +168,7 @@ static int tda10071_cmd_execute(struct tda10071_priv *priv, | |||
170 | usleep_range(200, 5000); | 168 | usleep_range(200, 5000); |
171 | } | 169 | } |
172 | 170 | ||
173 | dbg("%s: loop=%d", __func__, i); | 171 | dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); |
174 | 172 | ||
175 | if (i == 0) { | 173 | if (i == 0) { |
176 | ret = -ETIMEDOUT; | 174 | ret = -ETIMEDOUT; |
@@ -179,7 +177,7 @@ static int tda10071_cmd_execute(struct tda10071_priv *priv, | |||
179 | 177 | ||
180 | return ret; | 178 | return ret; |
181 | error: | 179 | error: |
182 | dbg("%s: failed=%d", __func__, ret); | 180 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
183 | return ret; | 181 | return ret; |
184 | } | 182 | } |
185 | 183 | ||
@@ -196,7 +194,8 @@ static int tda10071_set_tone(struct dvb_frontend *fe, | |||
196 | goto error; | 194 | goto error; |
197 | } | 195 | } |
198 | 196 | ||
199 | dbg("%s: tone_mode=%d", __func__, fe_sec_tone_mode); | 197 | dev_dbg(&priv->i2c->dev, "%s: tone_mode=%d\n", __func__, |
198 | fe_sec_tone_mode); | ||
200 | 199 | ||
201 | switch (fe_sec_tone_mode) { | 200 | switch (fe_sec_tone_mode) { |
202 | case SEC_TONE_ON: | 201 | case SEC_TONE_ON: |
@@ -206,24 +205,25 @@ static int tda10071_set_tone(struct dvb_frontend *fe, | |||
206 | tone = 0; | 205 | tone = 0; |
207 | break; | 206 | break; |
208 | default: | 207 | default: |
209 | dbg("%s: invalid fe_sec_tone_mode", __func__); | 208 | dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_tone_mode\n", |
209 | __func__); | ||
210 | ret = -EINVAL; | 210 | ret = -EINVAL; |
211 | goto error; | 211 | goto error; |
212 | } | 212 | } |
213 | 213 | ||
214 | cmd.args[0x00] = CMD_LNB_PCB_CONFIG; | 214 | cmd.args[0] = CMD_LNB_PCB_CONFIG; |
215 | cmd.args[0x01] = 0; | 215 | cmd.args[1] = 0; |
216 | cmd.args[0x02] = 0x00; | 216 | cmd.args[2] = 0x00; |
217 | cmd.args[0x03] = 0x00; | 217 | cmd.args[3] = 0x00; |
218 | cmd.args[0x04] = tone; | 218 | cmd.args[4] = tone; |
219 | cmd.len = 0x05; | 219 | cmd.len = 5; |
220 | ret = tda10071_cmd_execute(priv, &cmd); | 220 | ret = tda10071_cmd_execute(priv, &cmd); |
221 | if (ret) | 221 | if (ret) |
222 | goto error; | 222 | goto error; |
223 | 223 | ||
224 | return ret; | 224 | return ret; |
225 | error: | 225 | error: |
226 | dbg("%s: failed=%d", __func__, ret); | 226 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
227 | return ret; | 227 | return ret; |
228 | } | 228 | } |
229 | 229 | ||
@@ -240,7 +240,7 @@ static int tda10071_set_voltage(struct dvb_frontend *fe, | |||
240 | goto error; | 240 | goto error; |
241 | } | 241 | } |
242 | 242 | ||
243 | dbg("%s: voltage=%d", __func__, fe_sec_voltage); | 243 | dev_dbg(&priv->i2c->dev, "%s: voltage=%d\n", __func__, fe_sec_voltage); |
244 | 244 | ||
245 | switch (fe_sec_voltage) { | 245 | switch (fe_sec_voltage) { |
246 | case SEC_VOLTAGE_13: | 246 | case SEC_VOLTAGE_13: |
@@ -253,22 +253,23 @@ static int tda10071_set_voltage(struct dvb_frontend *fe, | |||
253 | voltage = 0; | 253 | voltage = 0; |
254 | break; | 254 | break; |
255 | default: | 255 | default: |
256 | dbg("%s: invalid fe_sec_voltage", __func__); | 256 | dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_voltage\n", |
257 | __func__); | ||
257 | ret = -EINVAL; | 258 | ret = -EINVAL; |
258 | goto error; | 259 | goto error; |
259 | }; | 260 | }; |
260 | 261 | ||
261 | cmd.args[0x00] = CMD_LNB_SET_DC_LEVEL; | 262 | cmd.args[0] = CMD_LNB_SET_DC_LEVEL; |
262 | cmd.args[0x01] = 0; | 263 | cmd.args[1] = 0; |
263 | cmd.args[0x02] = voltage; | 264 | cmd.args[2] = voltage; |
264 | cmd.len = 0x03; | 265 | cmd.len = 3; |
265 | ret = tda10071_cmd_execute(priv, &cmd); | 266 | ret = tda10071_cmd_execute(priv, &cmd); |
266 | if (ret) | 267 | if (ret) |
267 | goto error; | 268 | goto error; |
268 | 269 | ||
269 | return ret; | 270 | return ret; |
270 | error: | 271 | error: |
271 | dbg("%s: failed=%d", __func__, ret); | 272 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
272 | return ret; | 273 | return ret; |
273 | } | 274 | } |
274 | 275 | ||
@@ -285,9 +286,10 @@ static int tda10071_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
285 | goto error; | 286 | goto error; |
286 | } | 287 | } |
287 | 288 | ||
288 | dbg("%s: msg_len=%d", __func__, diseqc_cmd->msg_len); | 289 | dev_dbg(&priv->i2c->dev, "%s: msg_len=%d\n", __func__, |
290 | diseqc_cmd->msg_len); | ||
289 | 291 | ||
290 | if (diseqc_cmd->msg_len < 3 || diseqc_cmd->msg_len > 16) { | 292 | if (diseqc_cmd->msg_len < 3 || diseqc_cmd->msg_len > 6) { |
291 | ret = -EINVAL; | 293 | ret = -EINVAL; |
292 | goto error; | 294 | goto error; |
293 | } | 295 | } |
@@ -301,7 +303,7 @@ static int tda10071_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
301 | usleep_range(10000, 20000); | 303 | usleep_range(10000, 20000); |
302 | } | 304 | } |
303 | 305 | ||
304 | dbg("%s: loop=%d", __func__, i); | 306 | dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); |
305 | 307 | ||
306 | if (i == 0) { | 308 | if (i == 0) { |
307 | ret = -ETIMEDOUT; | 309 | ret = -ETIMEDOUT; |
@@ -312,22 +314,22 @@ static int tda10071_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
312 | if (ret) | 314 | if (ret) |
313 | goto error; | 315 | goto error; |
314 | 316 | ||
315 | cmd.args[0x00] = CMD_LNB_SEND_DISEQC; | 317 | cmd.args[0] = CMD_LNB_SEND_DISEQC; |
316 | cmd.args[0x01] = 0; | 318 | cmd.args[1] = 0; |
317 | cmd.args[0x02] = 0; | 319 | cmd.args[2] = 0; |
318 | cmd.args[0x03] = 0; | 320 | cmd.args[3] = 0; |
319 | cmd.args[0x04] = 2; | 321 | cmd.args[4] = 2; |
320 | cmd.args[0x05] = 0; | 322 | cmd.args[5] = 0; |
321 | cmd.args[0x06] = diseqc_cmd->msg_len; | 323 | cmd.args[6] = diseqc_cmd->msg_len; |
322 | memcpy(&cmd.args[0x07], diseqc_cmd->msg, diseqc_cmd->msg_len); | 324 | memcpy(&cmd.args[7], diseqc_cmd->msg, diseqc_cmd->msg_len); |
323 | cmd.len = 0x07 + diseqc_cmd->msg_len; | 325 | cmd.len = 7 + diseqc_cmd->msg_len; |
324 | ret = tda10071_cmd_execute(priv, &cmd); | 326 | ret = tda10071_cmd_execute(priv, &cmd); |
325 | if (ret) | 327 | if (ret) |
326 | goto error; | 328 | goto error; |
327 | 329 | ||
328 | return ret; | 330 | return ret; |
329 | error: | 331 | error: |
330 | dbg("%s: failed=%d", __func__, ret); | 332 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
331 | return ret; | 333 | return ret; |
332 | } | 334 | } |
333 | 335 | ||
@@ -344,7 +346,7 @@ static int tda10071_diseqc_recv_slave_reply(struct dvb_frontend *fe, | |||
344 | goto error; | 346 | goto error; |
345 | } | 347 | } |
346 | 348 | ||
347 | dbg("%s:", __func__); | 349 | dev_dbg(&priv->i2c->dev, "%s:\n", __func__); |
348 | 350 | ||
349 | /* wait LNB RX */ | 351 | /* wait LNB RX */ |
350 | for (i = 500, tmp = 0; i && !tmp; i--) { | 352 | for (i = 500, tmp = 0; i && !tmp; i--) { |
@@ -355,7 +357,7 @@ static int tda10071_diseqc_recv_slave_reply(struct dvb_frontend *fe, | |||
355 | usleep_range(10000, 20000); | 357 | usleep_range(10000, 20000); |
356 | } | 358 | } |
357 | 359 | ||
358 | dbg("%s: loop=%d", __func__, i); | 360 | dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); |
359 | 361 | ||
360 | if (i == 0) { | 362 | if (i == 0) { |
361 | ret = -ETIMEDOUT; | 363 | ret = -ETIMEDOUT; |
@@ -372,9 +374,9 @@ static int tda10071_diseqc_recv_slave_reply(struct dvb_frontend *fe, | |||
372 | reply->msg_len = sizeof(reply->msg); /* truncate API max */ | 374 | reply->msg_len = sizeof(reply->msg); /* truncate API max */ |
373 | 375 | ||
374 | /* read reply */ | 376 | /* read reply */ |
375 | cmd.args[0x00] = CMD_LNB_UPDATE_REPLY; | 377 | cmd.args[0] = CMD_LNB_UPDATE_REPLY; |
376 | cmd.args[0x01] = 0; | 378 | cmd.args[1] = 0; |
377 | cmd.len = 0x02; | 379 | cmd.len = 2; |
378 | ret = tda10071_cmd_execute(priv, &cmd); | 380 | ret = tda10071_cmd_execute(priv, &cmd); |
379 | if (ret) | 381 | if (ret) |
380 | goto error; | 382 | goto error; |
@@ -385,7 +387,7 @@ static int tda10071_diseqc_recv_slave_reply(struct dvb_frontend *fe, | |||
385 | 387 | ||
386 | return ret; | 388 | return ret; |
387 | error: | 389 | error: |
388 | dbg("%s: failed=%d", __func__, ret); | 390 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
389 | return ret; | 391 | return ret; |
390 | } | 392 | } |
391 | 393 | ||
@@ -402,7 +404,8 @@ static int tda10071_diseqc_send_burst(struct dvb_frontend *fe, | |||
402 | goto error; | 404 | goto error; |
403 | } | 405 | } |
404 | 406 | ||
405 | dbg("%s: fe_sec_mini_cmd=%d", __func__, fe_sec_mini_cmd); | 407 | dev_dbg(&priv->i2c->dev, "%s: fe_sec_mini_cmd=%d\n", __func__, |
408 | fe_sec_mini_cmd); | ||
406 | 409 | ||
407 | switch (fe_sec_mini_cmd) { | 410 | switch (fe_sec_mini_cmd) { |
408 | case SEC_MINI_A: | 411 | case SEC_MINI_A: |
@@ -412,7 +415,8 @@ static int tda10071_diseqc_send_burst(struct dvb_frontend *fe, | |||
412 | burst = 1; | 415 | burst = 1; |
413 | break; | 416 | break; |
414 | default: | 417 | default: |
415 | dbg("%s: invalid fe_sec_mini_cmd", __func__); | 418 | dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_mini_cmd\n", |
419 | __func__); | ||
416 | ret = -EINVAL; | 420 | ret = -EINVAL; |
417 | goto error; | 421 | goto error; |
418 | } | 422 | } |
@@ -426,7 +430,7 @@ static int tda10071_diseqc_send_burst(struct dvb_frontend *fe, | |||
426 | usleep_range(10000, 20000); | 430 | usleep_range(10000, 20000); |
427 | } | 431 | } |
428 | 432 | ||
429 | dbg("%s: loop=%d", __func__, i); | 433 | dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); |
430 | 434 | ||
431 | if (i == 0) { | 435 | if (i == 0) { |
432 | ret = -ETIMEDOUT; | 436 | ret = -ETIMEDOUT; |
@@ -437,17 +441,17 @@ static int tda10071_diseqc_send_burst(struct dvb_frontend *fe, | |||
437 | if (ret) | 441 | if (ret) |
438 | goto error; | 442 | goto error; |
439 | 443 | ||
440 | cmd.args[0x00] = CMD_LNB_SEND_TONEBURST; | 444 | cmd.args[0] = CMD_LNB_SEND_TONEBURST; |
441 | cmd.args[0x01] = 0; | 445 | cmd.args[1] = 0; |
442 | cmd.args[0x02] = burst; | 446 | cmd.args[2] = burst; |
443 | cmd.len = 0x03; | 447 | cmd.len = 3; |
444 | ret = tda10071_cmd_execute(priv, &cmd); | 448 | ret = tda10071_cmd_execute(priv, &cmd); |
445 | if (ret) | 449 | if (ret) |
446 | goto error; | 450 | goto error; |
447 | 451 | ||
448 | return ret; | 452 | return ret; |
449 | error: | 453 | error: |
450 | dbg("%s: failed=%d", __func__, ret); | 454 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
451 | return ret; | 455 | return ret; |
452 | } | 456 | } |
453 | 457 | ||
@@ -481,7 +485,7 @@ static int tda10071_read_status(struct dvb_frontend *fe, fe_status_t *status) | |||
481 | 485 | ||
482 | return ret; | 486 | return ret; |
483 | error: | 487 | error: |
484 | dbg("%s: failed=%d", __func__, ret); | 488 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
485 | return ret; | 489 | return ret; |
486 | } | 490 | } |
487 | 491 | ||
@@ -506,7 +510,7 @@ static int tda10071_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
506 | 510 | ||
507 | return ret; | 511 | return ret; |
508 | error: | 512 | error: |
509 | dbg("%s: failed=%d", __func__, ret); | 513 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
510 | return ret; | 514 | return ret; |
511 | } | 515 | } |
512 | 516 | ||
@@ -523,9 +527,9 @@ static int tda10071_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
523 | goto error; | 527 | goto error; |
524 | } | 528 | } |
525 | 529 | ||
526 | cmd.args[0x00] = CMD_GET_AGCACC; | 530 | cmd.args[0] = CMD_GET_AGCACC; |
527 | cmd.args[0x01] = 0; | 531 | cmd.args[1] = 0; |
528 | cmd.len = 0x02; | 532 | cmd.len = 2; |
529 | ret = tda10071_cmd_execute(priv, &cmd); | 533 | ret = tda10071_cmd_execute(priv, &cmd); |
530 | if (ret) | 534 | if (ret) |
531 | goto error; | 535 | goto error; |
@@ -545,7 +549,7 @@ static int tda10071_read_signal_strength(struct dvb_frontend *fe, u16 *strength) | |||
545 | 549 | ||
546 | return ret; | 550 | return ret; |
547 | error: | 551 | error: |
548 | dbg("%s: failed=%d", __func__, ret); | 552 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
549 | return ret; | 553 | return ret; |
550 | } | 554 | } |
551 | 555 | ||
@@ -583,17 +587,18 @@ static int tda10071_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
583 | goto error; | 587 | goto error; |
584 | 588 | ||
585 | if (priv->meas_count[i] == tmp) { | 589 | if (priv->meas_count[i] == tmp) { |
586 | dbg("%s: meas not ready=%02x", __func__, tmp); | 590 | dev_dbg(&priv->i2c->dev, "%s: meas not ready=%02x\n", __func__, |
591 | tmp); | ||
587 | *ber = priv->ber; | 592 | *ber = priv->ber; |
588 | return 0; | 593 | return 0; |
589 | } else { | 594 | } else { |
590 | priv->meas_count[i] = tmp; | 595 | priv->meas_count[i] = tmp; |
591 | } | 596 | } |
592 | 597 | ||
593 | cmd.args[0x00] = CMD_BER_UPDATE_COUNTERS; | 598 | cmd.args[0] = CMD_BER_UPDATE_COUNTERS; |
594 | cmd.args[0x01] = 0; | 599 | cmd.args[1] = 0; |
595 | cmd.args[0x02] = i; | 600 | cmd.args[2] = i; |
596 | cmd.len = 0x03; | 601 | cmd.len = 3; |
597 | ret = tda10071_cmd_execute(priv, &cmd); | 602 | ret = tda10071_cmd_execute(priv, &cmd); |
598 | if (ret) | 603 | if (ret) |
599 | goto error; | 604 | goto error; |
@@ -612,7 +617,7 @@ static int tda10071_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
612 | 617 | ||
613 | return ret; | 618 | return ret; |
614 | error: | 619 | error: |
615 | dbg("%s: failed=%d", __func__, ret); | 620 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
616 | return ret; | 621 | return ret; |
617 | } | 622 | } |
618 | 623 | ||
@@ -632,7 +637,7 @@ static int tda10071_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | |||
632 | 637 | ||
633 | return ret; | 638 | return ret; |
634 | error: | 639 | error: |
635 | dbg("%s: failed=%d", __func__, ret); | 640 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
636 | return ret; | 641 | return ret; |
637 | } | 642 | } |
638 | 643 | ||
@@ -644,10 +649,11 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
644 | int ret, i; | 649 | int ret, i; |
645 | u8 mode, rolloff, pilot, inversion, div; | 650 | u8 mode, rolloff, pilot, inversion, div; |
646 | 651 | ||
647 | dbg("%s: delivery_system=%d modulation=%d frequency=%d " \ | 652 | dev_dbg(&priv->i2c->dev, "%s: delivery_system=%d modulation=%d " \ |
648 | "symbol_rate=%d inversion=%d pilot=%d rolloff=%d", __func__, | 653 | "frequency=%d symbol_rate=%d inversion=%d pilot=%d " \ |
649 | c->delivery_system, c->modulation, c->frequency, | 654 | "rolloff=%d\n", __func__, c->delivery_system, c->modulation, |
650 | c->symbol_rate, c->inversion, c->pilot, c->rolloff); | 655 | c->frequency, c->symbol_rate, c->inversion, c->pilot, |
656 | c->rolloff); | ||
651 | 657 | ||
652 | priv->delivery_system = SYS_UNDEFINED; | 658 | priv->delivery_system = SYS_UNDEFINED; |
653 | 659 | ||
@@ -669,7 +675,7 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
669 | inversion = 3; | 675 | inversion = 3; |
670 | break; | 676 | break; |
671 | default: | 677 | default: |
672 | dbg("%s: invalid inversion", __func__); | 678 | dev_dbg(&priv->i2c->dev, "%s: invalid inversion\n", __func__); |
673 | ret = -EINVAL; | 679 | ret = -EINVAL; |
674 | goto error; | 680 | goto error; |
675 | } | 681 | } |
@@ -692,7 +698,8 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
692 | break; | 698 | break; |
693 | case ROLLOFF_AUTO: | 699 | case ROLLOFF_AUTO: |
694 | default: | 700 | default: |
695 | dbg("%s: invalid rolloff", __func__); | 701 | dev_dbg(&priv->i2c->dev, "%s: invalid rolloff\n", |
702 | __func__); | ||
696 | ret = -EINVAL; | 703 | ret = -EINVAL; |
697 | goto error; | 704 | goto error; |
698 | } | 705 | } |
@@ -708,13 +715,15 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
708 | pilot = 2; | 715 | pilot = 2; |
709 | break; | 716 | break; |
710 | default: | 717 | default: |
711 | dbg("%s: invalid pilot", __func__); | 718 | dev_dbg(&priv->i2c->dev, "%s: invalid pilot\n", |
719 | __func__); | ||
712 | ret = -EINVAL; | 720 | ret = -EINVAL; |
713 | goto error; | 721 | goto error; |
714 | } | 722 | } |
715 | break; | 723 | break; |
716 | default: | 724 | default: |
717 | dbg("%s: invalid delivery_system", __func__); | 725 | dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", |
726 | __func__); | ||
718 | ret = -EINVAL; | 727 | ret = -EINVAL; |
719 | goto error; | 728 | goto error; |
720 | } | 729 | } |
@@ -724,13 +733,15 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
724 | c->modulation == TDA10071_MODCOD[i].modulation && | 733 | c->modulation == TDA10071_MODCOD[i].modulation && |
725 | c->fec_inner == TDA10071_MODCOD[i].fec) { | 734 | c->fec_inner == TDA10071_MODCOD[i].fec) { |
726 | mode = TDA10071_MODCOD[i].val; | 735 | mode = TDA10071_MODCOD[i].val; |
727 | dbg("%s: mode found=%02x", __func__, mode); | 736 | dev_dbg(&priv->i2c->dev, "%s: mode found=%02x\n", |
737 | __func__, mode); | ||
728 | break; | 738 | break; |
729 | } | 739 | } |
730 | } | 740 | } |
731 | 741 | ||
732 | if (mode == 0xff) { | 742 | if (mode == 0xff) { |
733 | dbg("%s: invalid parameter combination", __func__); | 743 | dev_dbg(&priv->i2c->dev, "%s: invalid parameter combination\n", |
744 | __func__); | ||
734 | ret = -EINVAL; | 745 | ret = -EINVAL; |
735 | goto error; | 746 | goto error; |
736 | } | 747 | } |
@@ -748,22 +759,22 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
748 | if (ret) | 759 | if (ret) |
749 | goto error; | 760 | goto error; |
750 | 761 | ||
751 | cmd.args[0x00] = CMD_CHANGE_CHANNEL; | 762 | cmd.args[0] = CMD_CHANGE_CHANNEL; |
752 | cmd.args[0x01] = 0; | 763 | cmd.args[1] = 0; |
753 | cmd.args[0x02] = mode; | 764 | cmd.args[2] = mode; |
754 | cmd.args[0x03] = (c->frequency >> 16) & 0xff; | 765 | cmd.args[3] = (c->frequency >> 16) & 0xff; |
755 | cmd.args[0x04] = (c->frequency >> 8) & 0xff; | 766 | cmd.args[4] = (c->frequency >> 8) & 0xff; |
756 | cmd.args[0x05] = (c->frequency >> 0) & 0xff; | 767 | cmd.args[5] = (c->frequency >> 0) & 0xff; |
757 | cmd.args[0x06] = ((c->symbol_rate / 1000) >> 8) & 0xff; | 768 | cmd.args[6] = ((c->symbol_rate / 1000) >> 8) & 0xff; |
758 | cmd.args[0x07] = ((c->symbol_rate / 1000) >> 0) & 0xff; | 769 | cmd.args[7] = ((c->symbol_rate / 1000) >> 0) & 0xff; |
759 | cmd.args[0x08] = (tda10071_ops.info.frequency_tolerance >> 8) & 0xff; | 770 | cmd.args[8] = (tda10071_ops.info.frequency_tolerance >> 8) & 0xff; |
760 | cmd.args[0x09] = (tda10071_ops.info.frequency_tolerance >> 0) & 0xff; | 771 | cmd.args[9] = (tda10071_ops.info.frequency_tolerance >> 0) & 0xff; |
761 | cmd.args[0x0a] = rolloff; | 772 | cmd.args[10] = rolloff; |
762 | cmd.args[0x0b] = inversion; | 773 | cmd.args[11] = inversion; |
763 | cmd.args[0x0c] = pilot; | 774 | cmd.args[12] = pilot; |
764 | cmd.args[0x0d] = 0x00; | 775 | cmd.args[13] = 0x00; |
765 | cmd.args[0x0e] = 0x00; | 776 | cmd.args[14] = 0x00; |
766 | cmd.len = 0x0f; | 777 | cmd.len = 15; |
767 | ret = tda10071_cmd_execute(priv, &cmd); | 778 | ret = tda10071_cmd_execute(priv, &cmd); |
768 | if (ret) | 779 | if (ret) |
769 | goto error; | 780 | goto error; |
@@ -772,7 +783,7 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
772 | 783 | ||
773 | return ret; | 784 | return ret; |
774 | error: | 785 | error: |
775 | dbg("%s: failed=%d", __func__, ret); | 786 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
776 | return ret; | 787 | return ret; |
777 | } | 788 | } |
778 | 789 | ||
@@ -829,7 +840,7 @@ static int tda10071_get_frontend(struct dvb_frontend *fe) | |||
829 | 840 | ||
830 | return ret; | 841 | return ret; |
831 | error: | 842 | error: |
832 | dbg("%s: failed=%d", __func__, ret); | 843 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
833 | return ret; | 844 | return ret; |
834 | } | 845 | } |
835 | 846 | ||
@@ -915,10 +926,10 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
915 | goto error; | 926 | goto error; |
916 | } | 927 | } |
917 | 928 | ||
918 | cmd.args[0x00] = CMD_SET_SLEEP_MODE; | 929 | cmd.args[0] = CMD_SET_SLEEP_MODE; |
919 | cmd.args[0x01] = 0; | 930 | cmd.args[1] = 0; |
920 | cmd.args[0x02] = 0; | 931 | cmd.args[2] = 0; |
921 | cmd.len = 0x03; | 932 | cmd.len = 3; |
922 | ret = tda10071_cmd_execute(priv, &cmd); | 933 | ret = tda10071_cmd_execute(priv, &cmd); |
923 | if (ret) | 934 | if (ret) |
924 | goto error; | 935 | goto error; |
@@ -929,10 +940,11 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
929 | /* request the firmware, this will block and timeout */ | 940 | /* request the firmware, this will block and timeout */ |
930 | ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); | 941 | ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); |
931 | if (ret) { | 942 | if (ret) { |
932 | err("did not find the firmware file. (%s) " | 943 | dev_err(&priv->i2c->dev, "%s: did not find the " \ |
933 | "Please see linux/Documentation/dvb/ for more" \ | 944 | "firmware file. (%s) Please see " \ |
934 | " details on firmware-problems. (%d)", | 945 | "linux/Documentation/dvb/ for more " \ |
935 | fw_file, ret); | 946 | "details on firmware-problems. (%d)\n", |
947 | KBUILD_MODNAME, fw_file, ret); | ||
936 | goto error; | 948 | goto error; |
937 | } | 949 | } |
938 | 950 | ||
@@ -961,10 +973,11 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
961 | if (ret) | 973 | if (ret) |
962 | goto error_release_firmware; | 974 | goto error_release_firmware; |
963 | 975 | ||
964 | info("found a '%s' in cold state, will try to load a firmware", | 976 | dev_info(&priv->i2c->dev, "%s: found a '%s' in cold state, " \ |
965 | tda10071_ops.info.name); | 977 | "will try to load a firmware\n", KBUILD_MODNAME, |
966 | 978 | tda10071_ops.info.name); | |
967 | info("downloading firmware from file '%s'", fw_file); | 979 | dev_info(&priv->i2c->dev, "%s: downloading firmware from " \ |
980 | "file '%s'\n", KBUILD_MODNAME, fw_file); | ||
968 | 981 | ||
969 | /* do not download last byte */ | 982 | /* do not download last byte */ |
970 | fw_size = fw->size - 1; | 983 | fw_size = fw->size - 1; |
@@ -978,7 +991,9 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
978 | ret = tda10071_wr_regs(priv, 0xfa, | 991 | ret = tda10071_wr_regs(priv, 0xfa, |
979 | (u8 *) &fw->data[fw_size - remaining], len); | 992 | (u8 *) &fw->data[fw_size - remaining], len); |
980 | if (ret) { | 993 | if (ret) { |
981 | err("firmware download failed=%d", ret); | 994 | dev_err(&priv->i2c->dev, "%s: firmware " \ |
995 | "download failed=%d\n", | ||
996 | KBUILD_MODNAME, ret); | ||
982 | if (ret) | 997 | if (ret) |
983 | goto error_release_firmware; | 998 | goto error_release_firmware; |
984 | } | 999 | } |
@@ -1002,15 +1017,16 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
1002 | goto error; | 1017 | goto error; |
1003 | 1018 | ||
1004 | if (tmp) { | 1019 | if (tmp) { |
1005 | info("firmware did not run"); | 1020 | dev_info(&priv->i2c->dev, "%s: firmware did not run\n", |
1021 | KBUILD_MODNAME); | ||
1006 | ret = -EFAULT; | 1022 | ret = -EFAULT; |
1007 | goto error; | 1023 | goto error; |
1008 | } else { | 1024 | } else { |
1009 | priv->warm = 1; | 1025 | priv->warm = 1; |
1010 | } | 1026 | } |
1011 | 1027 | ||
1012 | cmd.args[0x00] = CMD_GET_FW_VERSION; | 1028 | cmd.args[0] = CMD_GET_FW_VERSION; |
1013 | cmd.len = 0x01; | 1029 | cmd.len = 1; |
1014 | ret = tda10071_cmd_execute(priv, &cmd); | 1030 | ret = tda10071_cmd_execute(priv, &cmd); |
1015 | if (ret) | 1031 | if (ret) |
1016 | goto error; | 1032 | goto error; |
@@ -1019,54 +1035,55 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
1019 | if (ret) | 1035 | if (ret) |
1020 | goto error; | 1036 | goto error; |
1021 | 1037 | ||
1022 | info("firmware version %d.%d.%d.%d", | 1038 | dev_info(&priv->i2c->dev, "%s: firmware version %d.%d.%d.%d\n", |
1023 | buf[0], buf[1], buf[2], buf[3]); | 1039 | KBUILD_MODNAME, buf[0], buf[1], buf[2], buf[3]); |
1024 | info("found a '%s' in warm state.", tda10071_ops.info.name); | 1040 | dev_info(&priv->i2c->dev, "%s: found a '%s' in warm state\n", |
1041 | KBUILD_MODNAME, tda10071_ops.info.name); | ||
1025 | 1042 | ||
1026 | ret = tda10071_rd_regs(priv, 0x81, buf, 2); | 1043 | ret = tda10071_rd_regs(priv, 0x81, buf, 2); |
1027 | if (ret) | 1044 | if (ret) |
1028 | goto error; | 1045 | goto error; |
1029 | 1046 | ||
1030 | cmd.args[0x00] = CMD_DEMOD_INIT; | 1047 | cmd.args[0] = CMD_DEMOD_INIT; |
1031 | cmd.args[0x01] = ((priv->cfg.xtal / 1000) >> 8) & 0xff; | 1048 | cmd.args[1] = ((priv->cfg.xtal / 1000) >> 8) & 0xff; |
1032 | cmd.args[0x02] = ((priv->cfg.xtal / 1000) >> 0) & 0xff; | 1049 | cmd.args[2] = ((priv->cfg.xtal / 1000) >> 0) & 0xff; |
1033 | cmd.args[0x03] = buf[0]; | 1050 | cmd.args[3] = buf[0]; |
1034 | cmd.args[0x04] = buf[1]; | 1051 | cmd.args[4] = buf[1]; |
1035 | cmd.args[0x05] = priv->cfg.pll_multiplier; | 1052 | cmd.args[5] = priv->cfg.pll_multiplier; |
1036 | cmd.args[0x06] = priv->cfg.spec_inv; | 1053 | cmd.args[6] = priv->cfg.spec_inv; |
1037 | cmd.args[0x07] = 0x00; | 1054 | cmd.args[7] = 0x00; |
1038 | cmd.len = 0x08; | 1055 | cmd.len = 8; |
1039 | ret = tda10071_cmd_execute(priv, &cmd); | 1056 | ret = tda10071_cmd_execute(priv, &cmd); |
1040 | if (ret) | 1057 | if (ret) |
1041 | goto error; | 1058 | goto error; |
1042 | 1059 | ||
1043 | cmd.args[0x00] = CMD_TUNER_INIT; | 1060 | cmd.args[0] = CMD_TUNER_INIT; |
1044 | cmd.args[0x01] = 0x00; | 1061 | cmd.args[1] = 0x00; |
1045 | cmd.args[0x02] = 0x00; | 1062 | cmd.args[2] = 0x00; |
1046 | cmd.args[0x03] = 0x00; | 1063 | cmd.args[3] = 0x00; |
1047 | cmd.args[0x04] = 0x00; | 1064 | cmd.args[4] = 0x00; |
1048 | cmd.args[0x05] = 0x14; | 1065 | cmd.args[5] = 0x14; |
1049 | cmd.args[0x06] = 0x00; | 1066 | cmd.args[6] = 0x00; |
1050 | cmd.args[0x07] = 0x03; | 1067 | cmd.args[7] = 0x03; |
1051 | cmd.args[0x08] = 0x02; | 1068 | cmd.args[8] = 0x02; |
1052 | cmd.args[0x09] = 0x02; | 1069 | cmd.args[9] = 0x02; |
1053 | cmd.args[0x0a] = 0x00; | 1070 | cmd.args[10] = 0x00; |
1054 | cmd.args[0x0b] = 0x00; | 1071 | cmd.args[11] = 0x00; |
1055 | cmd.args[0x0c] = 0x00; | 1072 | cmd.args[12] = 0x00; |
1056 | cmd.args[0x0d] = 0x00; | 1073 | cmd.args[13] = 0x00; |
1057 | cmd.args[0x0e] = 0x00; | 1074 | cmd.args[14] = 0x00; |
1058 | cmd.len = 0x0f; | 1075 | cmd.len = 15; |
1059 | ret = tda10071_cmd_execute(priv, &cmd); | 1076 | ret = tda10071_cmd_execute(priv, &cmd); |
1060 | if (ret) | 1077 | if (ret) |
1061 | goto error; | 1078 | goto error; |
1062 | 1079 | ||
1063 | cmd.args[0x00] = CMD_MPEG_CONFIG; | 1080 | cmd.args[0] = CMD_MPEG_CONFIG; |
1064 | cmd.args[0x01] = 0; | 1081 | cmd.args[1] = 0; |
1065 | cmd.args[0x02] = priv->cfg.ts_mode; | 1082 | cmd.args[2] = priv->cfg.ts_mode; |
1066 | cmd.args[0x03] = 0x00; | 1083 | cmd.args[3] = 0x00; |
1067 | cmd.args[0x04] = 0x04; | 1084 | cmd.args[4] = 0x04; |
1068 | cmd.args[0x05] = 0x00; | 1085 | cmd.args[5] = 0x00; |
1069 | cmd.len = 0x06; | 1086 | cmd.len = 6; |
1070 | ret = tda10071_cmd_execute(priv, &cmd); | 1087 | ret = tda10071_cmd_execute(priv, &cmd); |
1071 | if (ret) | 1088 | if (ret) |
1072 | goto error; | 1089 | goto error; |
@@ -1075,27 +1092,27 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
1075 | if (ret) | 1092 | if (ret) |
1076 | goto error; | 1093 | goto error; |
1077 | 1094 | ||
1078 | cmd.args[0x00] = CMD_LNB_CONFIG; | 1095 | cmd.args[0] = CMD_LNB_CONFIG; |
1079 | cmd.args[0x01] = 0; | 1096 | cmd.args[1] = 0; |
1080 | cmd.args[0x02] = 150; | 1097 | cmd.args[2] = 150; |
1081 | cmd.args[0x03] = 3; | 1098 | cmd.args[3] = 3; |
1082 | cmd.args[0x04] = 22; | 1099 | cmd.args[4] = 22; |
1083 | cmd.args[0x05] = 1; | 1100 | cmd.args[5] = 1; |
1084 | cmd.args[0x06] = 1; | 1101 | cmd.args[6] = 1; |
1085 | cmd.args[0x07] = 30; | 1102 | cmd.args[7] = 30; |
1086 | cmd.args[0x08] = 30; | 1103 | cmd.args[8] = 30; |
1087 | cmd.args[0x09] = 30; | 1104 | cmd.args[9] = 30; |
1088 | cmd.args[0x0a] = 30; | 1105 | cmd.args[10] = 30; |
1089 | cmd.len = 0x0b; | 1106 | cmd.len = 11; |
1090 | ret = tda10071_cmd_execute(priv, &cmd); | 1107 | ret = tda10071_cmd_execute(priv, &cmd); |
1091 | if (ret) | 1108 | if (ret) |
1092 | goto error; | 1109 | goto error; |
1093 | 1110 | ||
1094 | cmd.args[0x00] = CMD_BER_CONTROL; | 1111 | cmd.args[0] = CMD_BER_CONTROL; |
1095 | cmd.args[0x01] = 0; | 1112 | cmd.args[1] = 0; |
1096 | cmd.args[0x02] = 14; | 1113 | cmd.args[2] = 14; |
1097 | cmd.args[0x03] = 14; | 1114 | cmd.args[3] = 14; |
1098 | cmd.len = 0x04; | 1115 | cmd.len = 4; |
1099 | ret = tda10071_cmd_execute(priv, &cmd); | 1116 | ret = tda10071_cmd_execute(priv, &cmd); |
1100 | if (ret) | 1117 | if (ret) |
1101 | goto error; | 1118 | goto error; |
@@ -1105,7 +1122,7 @@ static int tda10071_init(struct dvb_frontend *fe) | |||
1105 | error_release_firmware: | 1122 | error_release_firmware: |
1106 | release_firmware(fw); | 1123 | release_firmware(fw); |
1107 | error: | 1124 | error: |
1108 | dbg("%s: failed=%d", __func__, ret); | 1125 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
1109 | return ret; | 1126 | return ret; |
1110 | } | 1127 | } |
1111 | 1128 | ||
@@ -1132,10 +1149,10 @@ static int tda10071_sleep(struct dvb_frontend *fe) | |||
1132 | goto error; | 1149 | goto error; |
1133 | } | 1150 | } |
1134 | 1151 | ||
1135 | cmd.args[0x00] = CMD_SET_SLEEP_MODE; | 1152 | cmd.args[0] = CMD_SET_SLEEP_MODE; |
1136 | cmd.args[0x01] = 0; | 1153 | cmd.args[1] = 0; |
1137 | cmd.args[0x02] = 1; | 1154 | cmd.args[2] = 1; |
1138 | cmd.len = 0x03; | 1155 | cmd.len = 3; |
1139 | ret = tda10071_cmd_execute(priv, &cmd); | 1156 | ret = tda10071_cmd_execute(priv, &cmd); |
1140 | if (ret) | 1157 | if (ret) |
1141 | goto error; | 1158 | goto error; |
@@ -1149,7 +1166,7 @@ static int tda10071_sleep(struct dvb_frontend *fe) | |||
1149 | 1166 | ||
1150 | return ret; | 1167 | return ret; |
1151 | error: | 1168 | error: |
1152 | dbg("%s: failed=%d", __func__, ret); | 1169 | dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); |
1153 | return ret; | 1170 | return ret; |
1154 | } | 1171 | } |
1155 | 1172 | ||
@@ -1208,7 +1225,7 @@ struct dvb_frontend *tda10071_attach(const struct tda10071_config *config, | |||
1208 | 1225 | ||
1209 | return &priv->fe; | 1226 | return &priv->fe; |
1210 | error: | 1227 | error: |
1211 | dbg("%s: failed=%d", __func__, ret); | 1228 | dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); |
1212 | kfree(priv); | 1229 | kfree(priv); |
1213 | return NULL; | 1230 | return NULL; |
1214 | } | 1231 | } |
diff --git a/drivers/media/dvb/frontends/tda10071_priv.h b/drivers/media/dvb/frontends/tda10071_priv.h index 93c5e6317f07..0fa85cfa70c2 100644 --- a/drivers/media/dvb/frontends/tda10071_priv.h +++ b/drivers/media/dvb/frontends/tda10071_priv.h | |||
@@ -25,19 +25,6 @@ | |||
25 | #include "tda10071.h" | 25 | #include "tda10071.h" |
26 | #include <linux/firmware.h> | 26 | #include <linux/firmware.h> |
27 | 27 | ||
28 | #define LOG_PREFIX "tda10071" | ||
29 | |||
30 | #undef dbg | ||
31 | #define dbg(f, arg...) \ | ||
32 | if (tda10071_debug) \ | ||
33 | printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
34 | #undef err | ||
35 | #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg) | ||
36 | #undef info | ||
37 | #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg) | ||
38 | #undef warn | ||
39 | #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg) | ||
40 | |||
41 | struct tda10071_priv { | 28 | struct tda10071_priv { |
42 | struct i2c_adapter *i2c; | 29 | struct i2c_adapter *i2c; |
43 | struct dvb_frontend fe; | 30 | struct dvb_frontend fe; |
@@ -112,7 +99,7 @@ struct tda10071_reg_val_mask { | |||
112 | #define CMD_BER_UPDATE_COUNTERS 0x3f | 99 | #define CMD_BER_UPDATE_COUNTERS 0x3f |
113 | 100 | ||
114 | /* firmare command struct */ | 101 | /* firmare command struct */ |
115 | #define TDA10071_ARGLEN 0x1e | 102 | #define TDA10071_ARGLEN 30 |
116 | struct tda10071_cmd { | 103 | struct tda10071_cmd { |
117 | u8 args[TDA10071_ARGLEN]; | 104 | u8 args[TDA10071_ARGLEN]; |
118 | u8 len; | 105 | u8 len; |
diff --git a/drivers/media/dvb/ngene/ngene-cards.c b/drivers/media/dvb/ngene/ngene-cards.c index 7539a5d71029..72ee8de02260 100644 --- a/drivers/media/dvb/ngene/ngene-cards.c +++ b/drivers/media/dvb/ngene/ngene-cards.c | |||
@@ -217,6 +217,7 @@ static int demod_attach_drxk(struct ngene_channel *chan, | |||
217 | 217 | ||
218 | memset(&config, 0, sizeof(config)); | 218 | memset(&config, 0, sizeof(config)); |
219 | config.microcode_name = "drxk_a3.mc"; | 219 | config.microcode_name = "drxk_a3.mc"; |
220 | config.qam_demod_parameter_count = 4; | ||
220 | config.adr = 0x29 + (chan->number ^ 2); | 221 | config.adr = 0x29 + (chan->number ^ 2); |
221 | 222 | ||
222 | chan->fe = dvb_attach(drxk_attach, &config, i2c); | 223 | chan->fe = dvb_attach(drxk_attach, &config, i2c); |
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index c257da13d766..24ce5a47f955 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -5,6 +5,7 @@ | |||
5 | menuconfig RADIO_ADAPTERS | 5 | menuconfig RADIO_ADAPTERS |
6 | bool "Radio Adapters" | 6 | bool "Radio Adapters" |
7 | depends on VIDEO_V4L2 | 7 | depends on VIDEO_V4L2 |
8 | depends on MEDIA_RADIO_SUPPORT | ||
8 | default y | 9 | default y |
9 | ---help--- | 10 | ---help--- |
10 | Say Y here to enable selecting AM/FM radio adapters. | 11 | Say Y here to enable selecting AM/FM radio adapters. |
diff --git a/drivers/media/radio/lm7000.h b/drivers/media/radio/lm7000.h new file mode 100644 index 000000000000..139cd6b68824 --- /dev/null +++ b/drivers/media/radio/lm7000.h | |||
@@ -0,0 +1,43 @@ | |||
1 | #ifndef __LM7000_H | ||
2 | #define __LM7000_H | ||
3 | |||
4 | /* Sanyo LM7000 tuner chip control | ||
5 | * | ||
6 | * Copyright 2012 Ondrej Zary <linux@rainbow-software.org> | ||
7 | * based on radio-aimslab.c by M. Kirkwood | ||
8 | * and radio-sf16fmi.c by M. Kirkwood and Petr Vandrovec | ||
9 | */ | ||
10 | |||
11 | #define LM7000_DATA (1 << 0) | ||
12 | #define LM7000_CLK (1 << 1) | ||
13 | #define LM7000_CE (1 << 2) | ||
14 | |||
15 | #define LM7000_FM_100 (0 << 20) | ||
16 | #define LM7000_FM_50 (1 << 20) | ||
17 | #define LM7000_FM_25 (2 << 20) | ||
18 | #define LM7000_BIT_FM (1 << 23) | ||
19 | |||
20 | static inline void lm7000_set_freq(u32 freq, void *handle, | ||
21 | void (*set_pins)(void *handle, u8 pins)) | ||
22 | { | ||
23 | int i; | ||
24 | u8 data; | ||
25 | u32 val; | ||
26 | |||
27 | freq += 171200; /* Add 10.7 MHz IF */ | ||
28 | freq /= 400; /* Convert to 25 kHz units */ | ||
29 | val = freq | LM7000_FM_25 | LM7000_BIT_FM; | ||
30 | /* write the 24-bit register, starting with LSB */ | ||
31 | for (i = 0; i < 24; i++) { | ||
32 | data = val & (1 << i) ? LM7000_DATA : 0; | ||
33 | set_pins(handle, data | LM7000_CE); | ||
34 | udelay(2); | ||
35 | set_pins(handle, data | LM7000_CE | LM7000_CLK); | ||
36 | udelay(2); | ||
37 | set_pins(handle, data | LM7000_CE); | ||
38 | udelay(2); | ||
39 | } | ||
40 | set_pins(handle, 0); | ||
41 | } | ||
42 | |||
43 | #endif /* __LM7000_H */ | ||
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c index 98e0c8c20312..12c70e876f58 100644 --- a/drivers/media/radio/radio-aimslab.c +++ b/drivers/media/radio/radio-aimslab.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <media/v4l2-ioctl.h> | 37 | #include <media/v4l2-ioctl.h> |
38 | #include <media/v4l2-ctrls.h> | 38 | #include <media/v4l2-ctrls.h> |
39 | #include "radio-isa.h" | 39 | #include "radio-isa.h" |
40 | #include "lm7000.h" | ||
40 | 41 | ||
41 | MODULE_AUTHOR("M. Kirkwood"); | 42 | MODULE_AUTHOR("M. Kirkwood"); |
42 | MODULE_DESCRIPTION("A driver for the RadioTrack/RadioReveal radio card."); | 43 | MODULE_DESCRIPTION("A driver for the RadioTrack/RadioReveal radio card."); |
@@ -72,55 +73,38 @@ static struct radio_isa_card *rtrack_alloc(void) | |||
72 | return rt ? &rt->isa : NULL; | 73 | return rt ? &rt->isa : NULL; |
73 | } | 74 | } |
74 | 75 | ||
75 | /* The 128+64 on these outb's is to keep the volume stable while tuning. | 76 | #define AIMS_BIT_TUN_CE (1 << 0) |
76 | * Without them, the volume _will_ creep up with each frequency change | 77 | #define AIMS_BIT_TUN_CLK (1 << 1) |
77 | * and bit 4 (+16) is to keep the signal strength meter enabled. | 78 | #define AIMS_BIT_TUN_DATA (1 << 2) |
78 | */ | 79 | #define AIMS_BIT_VOL_CE (1 << 3) |
80 | #define AIMS_BIT_TUN_STRQ (1 << 4) | ||
81 | /* bit 5 is not connected */ | ||
82 | #define AIMS_BIT_VOL_UP (1 << 6) /* active low */ | ||
83 | #define AIMS_BIT_VOL_DN (1 << 7) /* active low */ | ||
79 | 84 | ||
80 | static void send_0_byte(struct radio_isa_card *isa, int on) | 85 | void rtrack_set_pins(void *handle, u8 pins) |
81 | { | 86 | { |
82 | outb_p(128+64+16+on+1, isa->io); /* wr-enable + data low */ | 87 | struct radio_isa_card *isa = handle; |
83 | outb_p(128+64+16+on+2+1, isa->io); /* clock */ | 88 | struct rtrack *rt = container_of(isa, struct rtrack, isa); |
84 | msleep(1); | 89 | u8 bits = AIMS_BIT_VOL_DN | AIMS_BIT_VOL_UP | AIMS_BIT_TUN_STRQ; |
85 | } | ||
86 | 90 | ||
87 | static void send_1_byte(struct radio_isa_card *isa, int on) | 91 | if (!v4l2_ctrl_g_ctrl(rt->isa.mute)) |
88 | { | 92 | bits |= AIMS_BIT_VOL_CE; |
89 | outb_p(128+64+16+on+4+1, isa->io); /* wr-enable+data high */ | 93 | |
90 | outb_p(128+64+16+on+4+2+1, isa->io); /* clock */ | 94 | if (pins & LM7000_DATA) |
91 | msleep(1); | 95 | bits |= AIMS_BIT_TUN_DATA; |
96 | if (pins & LM7000_CLK) | ||
97 | bits |= AIMS_BIT_TUN_CLK; | ||
98 | if (pins & LM7000_CE) | ||
99 | bits |= AIMS_BIT_TUN_CE; | ||
100 | |||
101 | outb_p(bits, rt->isa.io); | ||
92 | } | 102 | } |
93 | 103 | ||
94 | static int rtrack_s_frequency(struct radio_isa_card *isa, u32 freq) | 104 | static int rtrack_s_frequency(struct radio_isa_card *isa, u32 freq) |
95 | { | 105 | { |
96 | int on = v4l2_ctrl_g_ctrl(isa->mute) ? 0 : 8; | 106 | lm7000_set_freq(freq, isa, rtrack_set_pins); |
97 | int i; | ||
98 | |||
99 | freq += 171200; /* Add 10.7 MHz IF */ | ||
100 | freq /= 800; /* Convert to 50 kHz units */ | ||
101 | |||
102 | send_0_byte(isa, on); /* 0: LSB of frequency */ | ||
103 | |||
104 | for (i = 0; i < 13; i++) /* : frequency bits (1-13) */ | ||
105 | if (freq & (1 << i)) | ||
106 | send_1_byte(isa, on); | ||
107 | else | ||
108 | send_0_byte(isa, on); | ||
109 | |||
110 | send_0_byte(isa, on); /* 14: test bit - always 0 */ | ||
111 | send_0_byte(isa, on); /* 15: test bit - always 0 */ | ||
112 | |||
113 | send_0_byte(isa, on); /* 16: band data 0 - always 0 */ | ||
114 | send_0_byte(isa, on); /* 17: band data 1 - always 0 */ | ||
115 | send_0_byte(isa, on); /* 18: band data 2 - always 0 */ | ||
116 | send_0_byte(isa, on); /* 19: time base - always 0 */ | ||
117 | |||
118 | send_0_byte(isa, on); /* 20: spacing (0 = 25 kHz) */ | ||
119 | send_1_byte(isa, on); /* 21: spacing (1 = 25 kHz) */ | ||
120 | send_0_byte(isa, on); /* 22: spacing (0 = 25 kHz) */ | ||
121 | send_1_byte(isa, on); /* 23: AM/FM (FM = 1, always) */ | ||
122 | 107 | ||
123 | outb(0xd0 + on, isa->io); /* volume steady + sigstr */ | ||
124 | return 0; | 108 | return 0; |
125 | } | 109 | } |
126 | 110 | ||
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 94cb6bc690f5..3182b26d6efa 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c | |||
@@ -295,7 +295,8 @@ static int vidioc_g_tuner(struct file *file, void *priv, | |||
295 | v->type = V4L2_TUNER_RADIO; | 295 | v->type = V4L2_TUNER_RADIO; |
296 | v->rangelow = FREQ_MIN * FREQ_MUL; | 296 | v->rangelow = FREQ_MIN * FREQ_MUL; |
297 | v->rangehigh = FREQ_MAX * FREQ_MUL; | 297 | v->rangehigh = FREQ_MAX * FREQ_MUL; |
298 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | 298 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | |
299 | V4L2_TUNER_CAP_HWSEEK_WRAP; | ||
299 | v->rxsubchans = is_stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; | 300 | v->rxsubchans = is_stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; |
300 | v->audmode = radio->stereo ? | 301 | v->audmode = radio->stereo ? |
301 | V4L2_TUNER_MODE_STEREO : V4L2_TUNER_MODE_MONO; | 302 | V4L2_TUNER_MODE_STEREO : V4L2_TUNER_MODE_MONO; |
@@ -372,7 +373,7 @@ static int vidioc_s_hw_freq_seek(struct file *file, void *priv, | |||
372 | timeout = jiffies + msecs_to_jiffies(30000); | 373 | timeout = jiffies + msecs_to_jiffies(30000); |
373 | for (;;) { | 374 | for (;;) { |
374 | if (time_after(jiffies, timeout)) { | 375 | if (time_after(jiffies, timeout)) { |
375 | retval = -EAGAIN; | 376 | retval = -ENODATA; |
376 | break; | 377 | break; |
377 | } | 378 | } |
378 | if (schedule_timeout_interruptible(msecs_to_jiffies(10))) { | 379 | if (schedule_timeout_interruptible(msecs_to_jiffies(10))) { |
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index a81d723b8c77..8185d5fbfa89 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/io.h> /* outb, outb_p */ | 27 | #include <linux/io.h> /* outb, outb_p */ |
28 | #include <media/v4l2-device.h> | 28 | #include <media/v4l2-device.h> |
29 | #include <media/v4l2-ioctl.h> | 29 | #include <media/v4l2-ioctl.h> |
30 | #include "lm7000.h" | ||
30 | 31 | ||
31 | MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); | 32 | MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); |
32 | MODULE_DESCRIPTION("A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio."); | 33 | MODULE_DESCRIPTION("A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio."); |
@@ -54,31 +55,33 @@ static struct fmi fmi_card; | |||
54 | static struct pnp_dev *dev; | 55 | static struct pnp_dev *dev; |
55 | bool pnp_attached; | 56 | bool pnp_attached; |
56 | 57 | ||
57 | /* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */ | ||
58 | /* It is only useful to give freq in interval of 800 (=0.05Mhz), | ||
59 | * other bits will be truncated, e.g 92.7400016 -> 92.7, but | ||
60 | * 92.7400017 -> 92.75 | ||
61 | */ | ||
62 | #define RSF16_ENCODE(x) ((x) / 800 + 214) | ||
63 | #define RSF16_MINFREQ (87 * 16000) | 58 | #define RSF16_MINFREQ (87 * 16000) |
64 | #define RSF16_MAXFREQ (108 * 16000) | 59 | #define RSF16_MAXFREQ (108 * 16000) |
65 | 60 | ||
66 | static void outbits(int bits, unsigned int data, int io) | 61 | #define FMI_BIT_TUN_CE (1 << 0) |
62 | #define FMI_BIT_TUN_CLK (1 << 1) | ||
63 | #define FMI_BIT_TUN_DATA (1 << 2) | ||
64 | #define FMI_BIT_VOL_SW (1 << 3) | ||
65 | #define FMI_BIT_TUN_STRQ (1 << 4) | ||
66 | |||
67 | void fmi_set_pins(void *handle, u8 pins) | ||
67 | { | 68 | { |
68 | while (bits--) { | 69 | struct fmi *fmi = handle; |
69 | if (data & 1) { | 70 | u8 bits = FMI_BIT_TUN_STRQ; |
70 | outb(5, io); | 71 | |
71 | udelay(6); | 72 | if (!fmi->mute) |
72 | outb(7, io); | 73 | bits |= FMI_BIT_VOL_SW; |
73 | udelay(6); | 74 | |
74 | } else { | 75 | if (pins & LM7000_DATA) |
75 | outb(1, io); | 76 | bits |= FMI_BIT_TUN_DATA; |
76 | udelay(6); | 77 | if (pins & LM7000_CLK) |
77 | outb(3, io); | 78 | bits |= FMI_BIT_TUN_CLK; |
78 | udelay(6); | 79 | if (pins & LM7000_CE) |
79 | } | 80 | bits |= FMI_BIT_TUN_CE; |
80 | data >>= 1; | 81 | |
81 | } | 82 | mutex_lock(&fmi->lock); |
83 | outb_p(bits, fmi->io); | ||
84 | mutex_unlock(&fmi->lock); | ||
82 | } | 85 | } |
83 | 86 | ||
84 | static inline void fmi_mute(struct fmi *fmi) | 87 | static inline void fmi_mute(struct fmi *fmi) |
@@ -95,20 +98,6 @@ static inline void fmi_unmute(struct fmi *fmi) | |||
95 | mutex_unlock(&fmi->lock); | 98 | mutex_unlock(&fmi->lock); |
96 | } | 99 | } |
97 | 100 | ||
98 | static inline int fmi_setfreq(struct fmi *fmi, unsigned long freq) | ||
99 | { | ||
100 | mutex_lock(&fmi->lock); | ||
101 | fmi->curfreq = freq; | ||
102 | |||
103 | outbits(16, RSF16_ENCODE(freq), fmi->io); | ||
104 | outbits(8, 0xC0, fmi->io); | ||
105 | msleep(143); /* was schedule_timeout(HZ/7) */ | ||
106 | mutex_unlock(&fmi->lock); | ||
107 | if (!fmi->mute) | ||
108 | fmi_unmute(fmi); | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | static inline int fmi_getsigstr(struct fmi *fmi) | 101 | static inline int fmi_getsigstr(struct fmi *fmi) |
113 | { | 102 | { |
114 | int val; | 103 | int val; |
@@ -173,7 +162,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
173 | return -EINVAL; | 162 | return -EINVAL; |
174 | /* rounding in steps of 800 to match the freq | 163 | /* rounding in steps of 800 to match the freq |
175 | that will be used */ | 164 | that will be used */ |
176 | fmi_setfreq(fmi, (f->frequency / 800) * 800); | 165 | lm7000_set_freq((f->frequency / 800) * 800, fmi, fmi_set_pins); |
177 | return 0; | 166 | return 0; |
178 | } | 167 | } |
179 | 168 | ||
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c index f1b607099b6c..e8428f573ccd 100644 --- a/drivers/media/radio/radio-wl1273.c +++ b/drivers/media/radio/radio-wl1273.c | |||
@@ -1514,7 +1514,8 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv, | |||
1514 | tuner->rangehigh = WL1273_FREQ(WL1273_BAND_OTHER_HIGH); | 1514 | tuner->rangehigh = WL1273_FREQ(WL1273_BAND_OTHER_HIGH); |
1515 | 1515 | ||
1516 | tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_RDS | | 1516 | tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_RDS | |
1517 | V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS_BLOCK_IO; | 1517 | V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS_BLOCK_IO | |
1518 | V4L2_TUNER_CAP_HWSEEK_BOUNDED | V4L2_TUNER_CAP_HWSEEK_WRAP; | ||
1518 | 1519 | ||
1519 | if (radio->stereo) | 1520 | if (radio->stereo) |
1520 | tuner->audmode = V4L2_TUNER_MODE_STEREO; | 1521 | tuner->audmode = V4L2_TUNER_MODE_STEREO; |
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c index 969cf494d85b..d485b79222fd 100644 --- a/drivers/media/radio/si470x/radio-si470x-common.c +++ b/drivers/media/radio/si470x/radio-si470x-common.c | |||
@@ -363,7 +363,7 @@ stop: | |||
363 | 363 | ||
364 | /* try again, if timed out */ | 364 | /* try again, if timed out */ |
365 | if (retval == 0 && timed_out) | 365 | if (retval == 0 && timed_out) |
366 | return -EAGAIN; | 366 | return -ENODATA; |
367 | return retval; | 367 | return retval; |
368 | } | 368 | } |
369 | 369 | ||
@@ -596,7 +596,9 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, | |||
596 | strcpy(tuner->name, "FM"); | 596 | strcpy(tuner->name, "FM"); |
597 | tuner->type = V4L2_TUNER_RADIO; | 597 | tuner->type = V4L2_TUNER_RADIO; |
598 | tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | | 598 | tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | |
599 | V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_BLOCK_IO; | 599 | V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_BLOCK_IO | |
600 | V4L2_TUNER_CAP_HWSEEK_BOUNDED | | ||
601 | V4L2_TUNER_CAP_HWSEEK_WRAP; | ||
600 | 602 | ||
601 | /* range limits */ | 603 | /* range limits */ |
602 | switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { | 604 | switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { |
diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c b/drivers/media/radio/wl128x/fmdrv_rx.c index 43fb72291bea..3dd9fc097c47 100644 --- a/drivers/media/radio/wl128x/fmdrv_rx.c +++ b/drivers/media/radio/wl128x/fmdrv_rx.c | |||
@@ -251,7 +251,7 @@ again: | |||
251 | if (!timeleft) { | 251 | if (!timeleft) { |
252 | fmerr("Timeout(%d sec),didn't get tune ended int\n", | 252 | fmerr("Timeout(%d sec),didn't get tune ended int\n", |
253 | jiffies_to_msecs(FM_DRV_RX_SEEK_TIMEOUT) / 1000); | 253 | jiffies_to_msecs(FM_DRV_RX_SEEK_TIMEOUT) / 1000); |
254 | return -ETIMEDOUT; | 254 | return -ENODATA; |
255 | } | 255 | } |
256 | 256 | ||
257 | int_reason = fmdev->irq_info.flag & (FM_TUNE_COMPLETE | FM_BAND_LIMIT); | 257 | int_reason = fmdev->irq_info.flag & (FM_TUNE_COMPLETE | FM_BAND_LIMIT); |
diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c index 080b96a61f1a..49a11ec1f449 100644 --- a/drivers/media/radio/wl128x/fmdrv_v4l2.c +++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c | |||
@@ -285,7 +285,9 @@ static int fm_v4l2_vidioc_g_tuner(struct file *file, void *priv, | |||
285 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO | | 285 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO | |
286 | ((fmdev->rx.rds.flag == FM_RDS_ENABLE) ? V4L2_TUNER_SUB_RDS : 0); | 286 | ((fmdev->rx.rds.flag == FM_RDS_ENABLE) ? V4L2_TUNER_SUB_RDS : 0); |
287 | tuner->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS | | 287 | tuner->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS | |
288 | V4L2_TUNER_CAP_LOW; | 288 | V4L2_TUNER_CAP_LOW | |
289 | V4L2_TUNER_CAP_HWSEEK_BOUNDED | | ||
290 | V4L2_TUNER_CAP_HWSEEK_WRAP; | ||
289 | tuner->audmode = (stereo_mono_mode ? | 291 | tuner->audmode = (stereo_mono_mode ? |
290 | V4L2_TUNER_MODE_MONO : V4L2_TUNER_MODE_STEREO); | 292 | V4L2_TUNER_MODE_MONO : V4L2_TUNER_MODE_STEREO); |
291 | 293 | ||
diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig index f97eeb870455..908ef70430e9 100644 --- a/drivers/media/rc/Kconfig +++ b/drivers/media/rc/Kconfig | |||
@@ -1,21 +1,20 @@ | |||
1 | menuconfig RC_CORE | 1 | config RC_CORE |
2 | tristate "Remote Controller adapters" | 2 | tristate |
3 | depends on MEDIA_RC_SUPPORT | ||
3 | depends on INPUT | 4 | depends on INPUT |
4 | default INPUT | 5 | default y |
5 | ---help--- | ||
6 | Enable support for Remote Controllers on Linux. This is | ||
7 | needed in order to support several video capture adapters, | ||
8 | standalone IR receivers/transmitters, and RF receivers. | ||
9 | 6 | ||
10 | Enable this option if you have a video capture board even | 7 | source "drivers/media/rc/keymaps/Kconfig" |
11 | if you don't need IR, as otherwise, you may not be able to | ||
12 | compile the driver for your adapter. | ||
13 | 8 | ||
14 | if RC_CORE | 9 | menuconfig RC_DECODERS |
10 | bool "Remote controller decoders" | ||
11 | depends on RC_CORE | ||
12 | default y | ||
15 | 13 | ||
14 | if RC_DECODERS | ||
16 | config LIRC | 15 | config LIRC |
17 | tristate | 16 | tristate "LIRC interface driver" |
18 | default y | 17 | depends on RC_CORE |
19 | 18 | ||
20 | ---help--- | 19 | ---help--- |
21 | Enable this option to build the Linux Infrared Remote | 20 | Enable this option to build the Linux Infrared Remote |
@@ -24,7 +23,16 @@ config LIRC | |||
24 | LIRC daemon handles protocol decoding for IR reception and | 23 | LIRC daemon handles protocol decoding for IR reception and |
25 | encoding for IR transmitting (aka "blasting"). | 24 | encoding for IR transmitting (aka "blasting"). |
26 | 25 | ||
27 | source "drivers/media/rc/keymaps/Kconfig" | 26 | config IR_LIRC_CODEC |
27 | tristate "Enable IR to LIRC bridge" | ||
28 | depends on RC_CORE | ||
29 | depends on LIRC | ||
30 | default y | ||
31 | |||
32 | ---help--- | ||
33 | Enable this option to pass raw IR to and from userspace via | ||
34 | the LIRC interface. | ||
35 | |||
28 | 36 | ||
29 | config IR_NEC_DECODER | 37 | config IR_NEC_DECODER |
30 | tristate "Enable IR raw decoder for the NEC protocol" | 38 | tristate "Enable IR raw decoder for the NEC protocol" |
@@ -108,16 +116,13 @@ config IR_MCE_KBD_DECODER | |||
108 | Enable this option if you have a Microsoft Remote Keyboard for | 116 | Enable this option if you have a Microsoft Remote Keyboard for |
109 | Windows Media Center Edition, which you would like to use with | 117 | Windows Media Center Edition, which you would like to use with |
110 | a raw IR receiver in your system. | 118 | a raw IR receiver in your system. |
119 | endif #RC_DECODERS | ||
111 | 120 | ||
112 | config IR_LIRC_CODEC | 121 | menuconfig RC_DEVICES |
113 | tristate "Enable IR to LIRC bridge" | 122 | bool "Remote Controller devices" |
114 | depends on RC_CORE | 123 | depends on RC_CORE |
115 | depends on LIRC | ||
116 | default y | ||
117 | 124 | ||
118 | ---help--- | 125 | if RC_DEVICES |
119 | Enable this option to pass raw IR to and from userspace via | ||
120 | the LIRC interface. | ||
121 | 126 | ||
122 | config RC_ATI_REMOTE | 127 | config RC_ATI_REMOTE |
123 | tristate "ATI / X10 based USB RF remote controls" | 128 | tristate "ATI / X10 based USB RF remote controls" |
@@ -276,4 +281,4 @@ config IR_GPIO_CIR | |||
276 | To compile this driver as a module, choose M here: the module will | 281 | To compile this driver as a module, choose M here: the module will |
277 | be called gpio-ir-recv. | 282 | be called gpio-ir-recv. |
278 | 283 | ||
279 | endif #RC_CORE | 284 | endif #RC_DEVICES |
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c index bef5296173c9..647dd951b0e8 100644 --- a/drivers/media/rc/ene_ir.c +++ b/drivers/media/rc/ene_ir.c | |||
@@ -1018,6 +1018,8 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) | |||
1018 | 1018 | ||
1019 | spin_lock_init(&dev->hw_lock); | 1019 | spin_lock_init(&dev->hw_lock); |
1020 | 1020 | ||
1021 | dev->hw_io = pnp_port_start(pnp_dev, 0); | ||
1022 | |||
1021 | pnp_set_drvdata(pnp_dev, dev); | 1023 | pnp_set_drvdata(pnp_dev, dev); |
1022 | dev->pnp_dev = pnp_dev; | 1024 | dev->pnp_dev = pnp_dev; |
1023 | 1025 | ||
@@ -1072,7 +1074,6 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) | |||
1072 | 1074 | ||
1073 | /* claim the resources */ | 1075 | /* claim the resources */ |
1074 | error = -EBUSY; | 1076 | error = -EBUSY; |
1075 | dev->hw_io = pnp_port_start(pnp_dev, 0); | ||
1076 | if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { | 1077 | if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { |
1077 | dev->hw_io = -1; | 1078 | dev->hw_io = -1; |
1078 | dev->irq = -1; | 1079 | dev->irq = -1; |
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c index 6aabf7ae3a31..ab30c64f8124 100644 --- a/drivers/media/rc/fintek-cir.c +++ b/drivers/media/rc/fintek-cir.c | |||
@@ -23,6 +23,8 @@ | |||
23 | * USA | 23 | * USA |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
27 | |||
26 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
27 | #include <linux/module.h> | 29 | #include <linux/module.h> |
28 | #include <linux/pnp.h> | 30 | #include <linux/pnp.h> |
@@ -110,30 +112,32 @@ static u8 fintek_cir_reg_read(struct fintek_dev *fintek, u8 offset) | |||
110 | return val; | 112 | return val; |
111 | } | 113 | } |
112 | 114 | ||
113 | #define pr_reg(text, ...) \ | ||
114 | printk(KERN_INFO KBUILD_MODNAME ": " text, ## __VA_ARGS__) | ||
115 | |||
116 | /* dump current cir register contents */ | 115 | /* dump current cir register contents */ |
117 | static void cir_dump_regs(struct fintek_dev *fintek) | 116 | static void cir_dump_regs(struct fintek_dev *fintek) |
118 | { | 117 | { |
119 | fintek_config_mode_enable(fintek); | 118 | fintek_config_mode_enable(fintek); |
120 | fintek_select_logical_dev(fintek, fintek->logical_dev_cir); | 119 | fintek_select_logical_dev(fintek, fintek->logical_dev_cir); |
121 | 120 | ||
122 | pr_reg("%s: Dump CIR logical device registers:\n", FINTEK_DRIVER_NAME); | 121 | pr_info("%s: Dump CIR logical device registers:\n", FINTEK_DRIVER_NAME); |
123 | pr_reg(" * CR CIR BASE ADDR: 0x%x\n", | 122 | pr_info(" * CR CIR BASE ADDR: 0x%x\n", |
124 | (fintek_cr_read(fintek, CIR_CR_BASE_ADDR_HI) << 8) | | 123 | (fintek_cr_read(fintek, CIR_CR_BASE_ADDR_HI) << 8) | |
125 | fintek_cr_read(fintek, CIR_CR_BASE_ADDR_LO)); | 124 | fintek_cr_read(fintek, CIR_CR_BASE_ADDR_LO)); |
126 | pr_reg(" * CR CIR IRQ NUM: 0x%x\n", | 125 | pr_info(" * CR CIR IRQ NUM: 0x%x\n", |
127 | fintek_cr_read(fintek, CIR_CR_IRQ_SEL)); | 126 | fintek_cr_read(fintek, CIR_CR_IRQ_SEL)); |
128 | 127 | ||
129 | fintek_config_mode_disable(fintek); | 128 | fintek_config_mode_disable(fintek); |
130 | 129 | ||
131 | pr_reg("%s: Dump CIR registers:\n", FINTEK_DRIVER_NAME); | 130 | pr_info("%s: Dump CIR registers:\n", FINTEK_DRIVER_NAME); |
132 | pr_reg(" * STATUS: 0x%x\n", fintek_cir_reg_read(fintek, CIR_STATUS)); | 131 | pr_info(" * STATUS: 0x%x\n", |
133 | pr_reg(" * CONTROL: 0x%x\n", fintek_cir_reg_read(fintek, CIR_CONTROL)); | 132 | fintek_cir_reg_read(fintek, CIR_STATUS)); |
134 | pr_reg(" * RX_DATA: 0x%x\n", fintek_cir_reg_read(fintek, CIR_RX_DATA)); | 133 | pr_info(" * CONTROL: 0x%x\n", |
135 | pr_reg(" * TX_CONTROL: 0x%x\n", fintek_cir_reg_read(fintek, CIR_TX_CONTROL)); | 134 | fintek_cir_reg_read(fintek, CIR_CONTROL)); |
136 | pr_reg(" * TX_DATA: 0x%x\n", fintek_cir_reg_read(fintek, CIR_TX_DATA)); | 135 | pr_info(" * RX_DATA: 0x%x\n", |
136 | fintek_cir_reg_read(fintek, CIR_RX_DATA)); | ||
137 | pr_info(" * TX_CONTROL: 0x%x\n", | ||
138 | fintek_cir_reg_read(fintek, CIR_TX_CONTROL)); | ||
139 | pr_info(" * TX_DATA: 0x%x\n", | ||
140 | fintek_cir_reg_read(fintek, CIR_TX_DATA)); | ||
137 | } | 141 | } |
138 | 142 | ||
139 | /* detect hardware features */ | 143 | /* detect hardware features */ |
diff --git a/drivers/media/rc/gpio-ir-recv.c b/drivers/media/rc/gpio-ir-recv.c index 0d875450c5ce..04cb272db16a 100644 --- a/drivers/media/rc/gpio-ir-recv.c +++ b/drivers/media/rc/gpio-ir-recv.c | |||
@@ -82,12 +82,21 @@ static int __devinit gpio_ir_recv_probe(struct platform_device *pdev) | |||
82 | goto err_allocate_device; | 82 | goto err_allocate_device; |
83 | } | 83 | } |
84 | 84 | ||
85 | rcdev->priv = gpio_dev; | ||
85 | rcdev->driver_type = RC_DRIVER_IR_RAW; | 86 | rcdev->driver_type = RC_DRIVER_IR_RAW; |
86 | rcdev->allowed_protos = RC_TYPE_ALL; | ||
87 | rcdev->input_name = GPIO_IR_DEVICE_NAME; | 87 | rcdev->input_name = GPIO_IR_DEVICE_NAME; |
88 | rcdev->input_phys = GPIO_IR_DEVICE_NAME "/input0"; | ||
88 | rcdev->input_id.bustype = BUS_HOST; | 89 | rcdev->input_id.bustype = BUS_HOST; |
90 | rcdev->input_id.vendor = 0x0001; | ||
91 | rcdev->input_id.product = 0x0001; | ||
92 | rcdev->input_id.version = 0x0100; | ||
93 | rcdev->dev.parent = &pdev->dev; | ||
89 | rcdev->driver_name = GPIO_IR_DRIVER_NAME; | 94 | rcdev->driver_name = GPIO_IR_DRIVER_NAME; |
90 | rcdev->map_name = RC_MAP_EMPTY; | 95 | if (pdata->allowed_protos) |
96 | rcdev->allowed_protos = pdata->allowed_protos; | ||
97 | else | ||
98 | rcdev->allowed_protos = RC_TYPE_ALL; | ||
99 | rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY; | ||
91 | 100 | ||
92 | gpio_dev->rcdev = rcdev; | 101 | gpio_dev->rcdev = rcdev; |
93 | gpio_dev->gpio_nr = pdata->gpio_nr; | 102 | gpio_dev->gpio_nr = pdata->gpio_nr; |
@@ -188,18 +197,7 @@ static struct platform_driver gpio_ir_recv_driver = { | |||
188 | #endif | 197 | #endif |
189 | }, | 198 | }, |
190 | }; | 199 | }; |
191 | 200 | module_platform_driver(gpio_ir_recv_driver); | |
192 | static int __init gpio_ir_recv_init(void) | ||
193 | { | ||
194 | return platform_driver_register(&gpio_ir_recv_driver); | ||
195 | } | ||
196 | module_init(gpio_ir_recv_init); | ||
197 | |||
198 | static void __exit gpio_ir_recv_exit(void) | ||
199 | { | ||
200 | platform_driver_unregister(&gpio_ir_recv_driver); | ||
201 | } | ||
202 | module_exit(gpio_ir_recv_exit); | ||
203 | 201 | ||
204 | MODULE_DESCRIPTION("GPIO IR Receiver driver"); | 202 | MODULE_DESCRIPTION("GPIO IR Receiver driver"); |
205 | MODULE_LICENSE("GPL v2"); | 203 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index dc8a7dddccd4..699eef39128b 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c | |||
@@ -25,6 +25,8 @@ | |||
25 | * USA | 25 | * USA |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
29 | |||
28 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
29 | #include <linux/module.h> | 31 | #include <linux/module.h> |
30 | #include <linux/pnp.h> | 32 | #include <linux/pnp.h> |
@@ -123,43 +125,40 @@ static u8 nvt_cir_wake_reg_read(struct nvt_dev *nvt, u8 offset) | |||
123 | return val; | 125 | return val; |
124 | } | 126 | } |
125 | 127 | ||
126 | #define pr_reg(text, ...) \ | ||
127 | printk(KERN_INFO KBUILD_MODNAME ": " text, ## __VA_ARGS__) | ||
128 | |||
129 | /* dump current cir register contents */ | 128 | /* dump current cir register contents */ |
130 | static void cir_dump_regs(struct nvt_dev *nvt) | 129 | static void cir_dump_regs(struct nvt_dev *nvt) |
131 | { | 130 | { |
132 | nvt_efm_enable(nvt); | 131 | nvt_efm_enable(nvt); |
133 | nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR); | 132 | nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR); |
134 | 133 | ||
135 | pr_reg("%s: Dump CIR logical device registers:\n", NVT_DRIVER_NAME); | 134 | pr_info("%s: Dump CIR logical device registers:\n", NVT_DRIVER_NAME); |
136 | pr_reg(" * CR CIR ACTIVE : 0x%x\n", | 135 | pr_info(" * CR CIR ACTIVE : 0x%x\n", |
137 | nvt_cr_read(nvt, CR_LOGICAL_DEV_EN)); | 136 | nvt_cr_read(nvt, CR_LOGICAL_DEV_EN)); |
138 | pr_reg(" * CR CIR BASE ADDR: 0x%x\n", | 137 | pr_info(" * CR CIR BASE ADDR: 0x%x\n", |
139 | (nvt_cr_read(nvt, CR_CIR_BASE_ADDR_HI) << 8) | | 138 | (nvt_cr_read(nvt, CR_CIR_BASE_ADDR_HI) << 8) | |
140 | nvt_cr_read(nvt, CR_CIR_BASE_ADDR_LO)); | 139 | nvt_cr_read(nvt, CR_CIR_BASE_ADDR_LO)); |
141 | pr_reg(" * CR CIR IRQ NUM: 0x%x\n", | 140 | pr_info(" * CR CIR IRQ NUM: 0x%x\n", |
142 | nvt_cr_read(nvt, CR_CIR_IRQ_RSRC)); | 141 | nvt_cr_read(nvt, CR_CIR_IRQ_RSRC)); |
143 | 142 | ||
144 | nvt_efm_disable(nvt); | 143 | nvt_efm_disable(nvt); |
145 | 144 | ||
146 | pr_reg("%s: Dump CIR registers:\n", NVT_DRIVER_NAME); | 145 | pr_info("%s: Dump CIR registers:\n", NVT_DRIVER_NAME); |
147 | pr_reg(" * IRCON: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IRCON)); | 146 | pr_info(" * IRCON: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IRCON)); |
148 | pr_reg(" * IRSTS: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IRSTS)); | 147 | pr_info(" * IRSTS: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IRSTS)); |
149 | pr_reg(" * IREN: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IREN)); | 148 | pr_info(" * IREN: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IREN)); |
150 | pr_reg(" * RXFCONT: 0x%x\n", nvt_cir_reg_read(nvt, CIR_RXFCONT)); | 149 | pr_info(" * RXFCONT: 0x%x\n", nvt_cir_reg_read(nvt, CIR_RXFCONT)); |
151 | pr_reg(" * CP: 0x%x\n", nvt_cir_reg_read(nvt, CIR_CP)); | 150 | pr_info(" * CP: 0x%x\n", nvt_cir_reg_read(nvt, CIR_CP)); |
152 | pr_reg(" * CC: 0x%x\n", nvt_cir_reg_read(nvt, CIR_CC)); | 151 | pr_info(" * CC: 0x%x\n", nvt_cir_reg_read(nvt, CIR_CC)); |
153 | pr_reg(" * SLCH: 0x%x\n", nvt_cir_reg_read(nvt, CIR_SLCH)); | 152 | pr_info(" * SLCH: 0x%x\n", nvt_cir_reg_read(nvt, CIR_SLCH)); |
154 | pr_reg(" * SLCL: 0x%x\n", nvt_cir_reg_read(nvt, CIR_SLCL)); | 153 | pr_info(" * SLCL: 0x%x\n", nvt_cir_reg_read(nvt, CIR_SLCL)); |
155 | pr_reg(" * FIFOCON: 0x%x\n", nvt_cir_reg_read(nvt, CIR_FIFOCON)); | 154 | pr_info(" * FIFOCON: 0x%x\n", nvt_cir_reg_read(nvt, CIR_FIFOCON)); |
156 | pr_reg(" * IRFIFOSTS: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IRFIFOSTS)); | 155 | pr_info(" * IRFIFOSTS: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IRFIFOSTS)); |
157 | pr_reg(" * SRXFIFO: 0x%x\n", nvt_cir_reg_read(nvt, CIR_SRXFIFO)); | 156 | pr_info(" * SRXFIFO: 0x%x\n", nvt_cir_reg_read(nvt, CIR_SRXFIFO)); |
158 | pr_reg(" * TXFCONT: 0x%x\n", nvt_cir_reg_read(nvt, CIR_TXFCONT)); | 157 | pr_info(" * TXFCONT: 0x%x\n", nvt_cir_reg_read(nvt, CIR_TXFCONT)); |
159 | pr_reg(" * STXFIFO: 0x%x\n", nvt_cir_reg_read(nvt, CIR_STXFIFO)); | 158 | pr_info(" * STXFIFO: 0x%x\n", nvt_cir_reg_read(nvt, CIR_STXFIFO)); |
160 | pr_reg(" * FCCH: 0x%x\n", nvt_cir_reg_read(nvt, CIR_FCCH)); | 159 | pr_info(" * FCCH: 0x%x\n", nvt_cir_reg_read(nvt, CIR_FCCH)); |
161 | pr_reg(" * FCCL: 0x%x\n", nvt_cir_reg_read(nvt, CIR_FCCL)); | 160 | pr_info(" * FCCL: 0x%x\n", nvt_cir_reg_read(nvt, CIR_FCCL)); |
162 | pr_reg(" * IRFSM: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IRFSM)); | 161 | pr_info(" * IRFSM: 0x%x\n", nvt_cir_reg_read(nvt, CIR_IRFSM)); |
163 | } | 162 | } |
164 | 163 | ||
165 | /* dump current cir wake register contents */ | 164 | /* dump current cir wake register contents */ |
@@ -170,59 +169,59 @@ static void cir_wake_dump_regs(struct nvt_dev *nvt) | |||
170 | nvt_efm_enable(nvt); | 169 | nvt_efm_enable(nvt); |
171 | nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE); | 170 | nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE); |
172 | 171 | ||
173 | pr_reg("%s: Dump CIR WAKE logical device registers:\n", | 172 | pr_info("%s: Dump CIR WAKE logical device registers:\n", |
174 | NVT_DRIVER_NAME); | 173 | NVT_DRIVER_NAME); |
175 | pr_reg(" * CR CIR WAKE ACTIVE : 0x%x\n", | 174 | pr_info(" * CR CIR WAKE ACTIVE : 0x%x\n", |
176 | nvt_cr_read(nvt, CR_LOGICAL_DEV_EN)); | 175 | nvt_cr_read(nvt, CR_LOGICAL_DEV_EN)); |
177 | pr_reg(" * CR CIR WAKE BASE ADDR: 0x%x\n", | 176 | pr_info(" * CR CIR WAKE BASE ADDR: 0x%x\n", |
178 | (nvt_cr_read(nvt, CR_CIR_BASE_ADDR_HI) << 8) | | 177 | (nvt_cr_read(nvt, CR_CIR_BASE_ADDR_HI) << 8) | |
179 | nvt_cr_read(nvt, CR_CIR_BASE_ADDR_LO)); | 178 | nvt_cr_read(nvt, CR_CIR_BASE_ADDR_LO)); |
180 | pr_reg(" * CR CIR WAKE IRQ NUM: 0x%x\n", | 179 | pr_info(" * CR CIR WAKE IRQ NUM: 0x%x\n", |
181 | nvt_cr_read(nvt, CR_CIR_IRQ_RSRC)); | 180 | nvt_cr_read(nvt, CR_CIR_IRQ_RSRC)); |
182 | 181 | ||
183 | nvt_efm_disable(nvt); | 182 | nvt_efm_disable(nvt); |
184 | 183 | ||
185 | pr_reg("%s: Dump CIR WAKE registers\n", NVT_DRIVER_NAME); | 184 | pr_info("%s: Dump CIR WAKE registers\n", NVT_DRIVER_NAME); |
186 | pr_reg(" * IRCON: 0x%x\n", | 185 | pr_info(" * IRCON: 0x%x\n", |
187 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON)); | 186 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON)); |
188 | pr_reg(" * IRSTS: 0x%x\n", | 187 | pr_info(" * IRSTS: 0x%x\n", |
189 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS)); | 188 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS)); |
190 | pr_reg(" * IREN: 0x%x\n", | 189 | pr_info(" * IREN: 0x%x\n", |
191 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN)); | 190 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN)); |
192 | pr_reg(" * FIFO CMP DEEP: 0x%x\n", | 191 | pr_info(" * FIFO CMP DEEP: 0x%x\n", |
193 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_CMP_DEEP)); | 192 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_CMP_DEEP)); |
194 | pr_reg(" * FIFO CMP TOL: 0x%x\n", | 193 | pr_info(" * FIFO CMP TOL: 0x%x\n", |
195 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_CMP_TOL)); | 194 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_CMP_TOL)); |
196 | pr_reg(" * FIFO COUNT: 0x%x\n", | 195 | pr_info(" * FIFO COUNT: 0x%x\n", |
197 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_COUNT)); | 196 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_COUNT)); |
198 | pr_reg(" * SLCH: 0x%x\n", | 197 | pr_info(" * SLCH: 0x%x\n", |
199 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_SLCH)); | 198 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_SLCH)); |
200 | pr_reg(" * SLCL: 0x%x\n", | 199 | pr_info(" * SLCL: 0x%x\n", |
201 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_SLCL)); | 200 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_SLCL)); |
202 | pr_reg(" * FIFOCON: 0x%x\n", | 201 | pr_info(" * FIFOCON: 0x%x\n", |
203 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFOCON)); | 202 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFOCON)); |
204 | pr_reg(" * SRXFSTS: 0x%x\n", | 203 | pr_info(" * SRXFSTS: 0x%x\n", |
205 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_SRXFSTS)); | 204 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_SRXFSTS)); |
206 | pr_reg(" * SAMPLE RX FIFO: 0x%x\n", | 205 | pr_info(" * SAMPLE RX FIFO: 0x%x\n", |
207 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_SAMPLE_RX_FIFO)); | 206 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_SAMPLE_RX_FIFO)); |
208 | pr_reg(" * WR FIFO DATA: 0x%x\n", | 207 | pr_info(" * WR FIFO DATA: 0x%x\n", |
209 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_WR_FIFO_DATA)); | 208 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_WR_FIFO_DATA)); |
210 | pr_reg(" * RD FIFO ONLY: 0x%x\n", | 209 | pr_info(" * RD FIFO ONLY: 0x%x\n", |
211 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY)); | 210 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY)); |
212 | pr_reg(" * RD FIFO ONLY IDX: 0x%x\n", | 211 | pr_info(" * RD FIFO ONLY IDX: 0x%x\n", |
213 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX)); | 212 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX)); |
214 | pr_reg(" * FIFO IGNORE: 0x%x\n", | 213 | pr_info(" * FIFO IGNORE: 0x%x\n", |
215 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_IGNORE)); | 214 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_IGNORE)); |
216 | pr_reg(" * IRFSM: 0x%x\n", | 215 | pr_info(" * IRFSM: 0x%x\n", |
217 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRFSM)); | 216 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRFSM)); |
218 | 217 | ||
219 | fifo_len = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_COUNT); | 218 | fifo_len = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFO_COUNT); |
220 | pr_reg("%s: Dump CIR WAKE FIFO (len %d)\n", NVT_DRIVER_NAME, fifo_len); | 219 | pr_info("%s: Dump CIR WAKE FIFO (len %d)\n", NVT_DRIVER_NAME, fifo_len); |
221 | pr_reg("* Contents = "); | 220 | pr_info("* Contents ="); |
222 | for (i = 0; i < fifo_len; i++) | 221 | for (i = 0; i < fifo_len; i++) |
223 | printk(KERN_CONT "%02x ", | 222 | pr_cont(" %02x", |
224 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY)); | 223 | nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY)); |
225 | printk(KERN_CONT "\n"); | 224 | pr_cont("\n"); |
226 | } | 225 | } |
227 | 226 | ||
228 | /* detect hardware features */ | 227 | /* detect hardware features */ |
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 99937c94d7df..c128fac0ce2c 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -5,7 +5,7 @@ | |||
5 | config VIDEO_V4L2 | 5 | config VIDEO_V4L2 |
6 | tristate | 6 | tristate |
7 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON | 7 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON |
8 | default VIDEO_DEV && VIDEO_V4L2_COMMON | 8 | default y |
9 | 9 | ||
10 | config VIDEOBUF_GEN | 10 | config VIDEOBUF_GEN |
11 | tristate | 11 | tristate |
@@ -73,6 +73,7 @@ config VIDEOBUF2_DMA_SG | |||
73 | menuconfig VIDEO_CAPTURE_DRIVERS | 73 | menuconfig VIDEO_CAPTURE_DRIVERS |
74 | bool "Video capture adapters" | 74 | bool "Video capture adapters" |
75 | depends on VIDEO_V4L2 | 75 | depends on VIDEO_V4L2 |
76 | depends on MEDIA_CAMERA_SUPPORT || MEDIA_ANALOG_TV_SUPPORT | ||
76 | default y | 77 | default y |
77 | ---help--- | 78 | ---help--- |
78 | Say Y here to enable selecting the video adapters for | 79 | Say Y here to enable selecting the video adapters for |
@@ -461,6 +462,15 @@ config VIDEO_ADV7343 | |||
461 | To compile this driver as a module, choose M here: the | 462 | To compile this driver as a module, choose M here: the |
462 | module will be called adv7343. | 463 | module will be called adv7343. |
463 | 464 | ||
465 | config VIDEO_ADV7393 | ||
466 | tristate "ADV7393 video encoder" | ||
467 | depends on I2C | ||
468 | help | ||
469 | Support for Analog Devices I2C bus based ADV7393 encoder. | ||
470 | |||
471 | To compile this driver as a module, choose M here: the | ||
472 | module will be called adv7393. | ||
473 | |||
464 | config VIDEO_AK881X | 474 | config VIDEO_AK881X |
465 | tristate "AK8813/AK8814 video encoders" | 475 | tristate "AK8813/AK8814 video encoders" |
466 | depends on I2C | 476 | depends on I2C |
@@ -478,6 +488,7 @@ config VIDEO_SMIAPP_PLL | |||
478 | config VIDEO_OV7670 | 488 | config VIDEO_OV7670 |
479 | tristate "OmniVision OV7670 sensor support" | 489 | tristate "OmniVision OV7670 sensor support" |
480 | depends on I2C && VIDEO_V4L2 | 490 | depends on I2C && VIDEO_V4L2 |
491 | depends on MEDIA_CAMERA_SUPPORT | ||
481 | ---help--- | 492 | ---help--- |
482 | This is a Video4Linux2 sensor-level driver for the OmniVision | 493 | This is a Video4Linux2 sensor-level driver for the OmniVision |
483 | OV7670 VGA camera. It currently only works with the M88ALP01 | 494 | OV7670 VGA camera. It currently only works with the M88ALP01 |
@@ -486,6 +497,7 @@ config VIDEO_OV7670 | |||
486 | config VIDEO_VS6624 | 497 | config VIDEO_VS6624 |
487 | tristate "ST VS6624 sensor support" | 498 | tristate "ST VS6624 sensor support" |
488 | depends on VIDEO_V4L2 && I2C | 499 | depends on VIDEO_V4L2 && I2C |
500 | depends on MEDIA_CAMERA_SUPPORT | ||
489 | ---help--- | 501 | ---help--- |
490 | This is a Video4Linux2 sensor-level driver for the ST VS6624 | 502 | This is a Video4Linux2 sensor-level driver for the ST VS6624 |
491 | camera. | 503 | camera. |
@@ -496,6 +508,7 @@ config VIDEO_VS6624 | |||
496 | config VIDEO_MT9M032 | 508 | config VIDEO_MT9M032 |
497 | tristate "MT9M032 camera sensor support" | 509 | tristate "MT9M032 camera sensor support" |
498 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API | 510 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API |
511 | depends on MEDIA_CAMERA_SUPPORT | ||
499 | select VIDEO_APTINA_PLL | 512 | select VIDEO_APTINA_PLL |
500 | ---help--- | 513 | ---help--- |
501 | This driver supports MT9M032 camera sensors from Aptina, monochrome | 514 | This driver supports MT9M032 camera sensors from Aptina, monochrome |
@@ -504,6 +517,7 @@ config VIDEO_MT9M032 | |||
504 | config VIDEO_MT9P031 | 517 | config VIDEO_MT9P031 |
505 | tristate "Aptina MT9P031 support" | 518 | tristate "Aptina MT9P031 support" |
506 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API | 519 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API |
520 | depends on MEDIA_CAMERA_SUPPORT | ||
507 | select VIDEO_APTINA_PLL | 521 | select VIDEO_APTINA_PLL |
508 | ---help--- | 522 | ---help--- |
509 | This is a Video4Linux2 sensor-level driver for the Aptina | 523 | This is a Video4Linux2 sensor-level driver for the Aptina |
@@ -512,6 +526,7 @@ config VIDEO_MT9P031 | |||
512 | config VIDEO_MT9T001 | 526 | config VIDEO_MT9T001 |
513 | tristate "Aptina MT9T001 support" | 527 | tristate "Aptina MT9T001 support" |
514 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API | 528 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API |
529 | depends on MEDIA_CAMERA_SUPPORT | ||
515 | ---help--- | 530 | ---help--- |
516 | This is a Video4Linux2 sensor-level driver for the Aptina | 531 | This is a Video4Linux2 sensor-level driver for the Aptina |
517 | (Micron) mt0t001 3 Mpixel camera. | 532 | (Micron) mt0t001 3 Mpixel camera. |
@@ -519,6 +534,7 @@ config VIDEO_MT9T001 | |||
519 | config VIDEO_MT9V011 | 534 | config VIDEO_MT9V011 |
520 | tristate "Micron mt9v011 sensor support" | 535 | tristate "Micron mt9v011 sensor support" |
521 | depends on I2C && VIDEO_V4L2 | 536 | depends on I2C && VIDEO_V4L2 |
537 | depends on MEDIA_CAMERA_SUPPORT | ||
522 | ---help--- | 538 | ---help--- |
523 | This is a Video4Linux2 sensor-level driver for the Micron | 539 | This is a Video4Linux2 sensor-level driver for the Micron |
524 | mt0v011 1.3 Mpixel camera. It currently only works with the | 540 | mt0v011 1.3 Mpixel camera. It currently only works with the |
@@ -527,6 +543,7 @@ config VIDEO_MT9V011 | |||
527 | config VIDEO_MT9V032 | 543 | config VIDEO_MT9V032 |
528 | tristate "Micron MT9V032 sensor support" | 544 | tristate "Micron MT9V032 sensor support" |
529 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API | 545 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API |
546 | depends on MEDIA_CAMERA_SUPPORT | ||
530 | ---help--- | 547 | ---help--- |
531 | This is a Video4Linux2 sensor-level driver for the Micron | 548 | This is a Video4Linux2 sensor-level driver for the Micron |
532 | MT9V032 752x480 CMOS sensor. | 549 | MT9V032 752x480 CMOS sensor. |
@@ -534,6 +551,7 @@ config VIDEO_MT9V032 | |||
534 | config VIDEO_TCM825X | 551 | config VIDEO_TCM825X |
535 | tristate "TCM825x camera sensor support" | 552 | tristate "TCM825x camera sensor support" |
536 | depends on I2C && VIDEO_V4L2 | 553 | depends on I2C && VIDEO_V4L2 |
554 | depends on MEDIA_CAMERA_SUPPORT | ||
537 | ---help--- | 555 | ---help--- |
538 | This is a driver for the Toshiba TCM825x VGA camera sensor. | 556 | This is a driver for the Toshiba TCM825x VGA camera sensor. |
539 | It is used for example in Nokia N800. | 557 | It is used for example in Nokia N800. |
@@ -541,12 +559,14 @@ config VIDEO_TCM825X | |||
541 | config VIDEO_SR030PC30 | 559 | config VIDEO_SR030PC30 |
542 | tristate "Siliconfile SR030PC30 sensor support" | 560 | tristate "Siliconfile SR030PC30 sensor support" |
543 | depends on I2C && VIDEO_V4L2 | 561 | depends on I2C && VIDEO_V4L2 |
562 | depends on MEDIA_CAMERA_SUPPORT | ||
544 | ---help--- | 563 | ---help--- |
545 | This driver supports SR030PC30 VGA camera from Siliconfile | 564 | This driver supports SR030PC30 VGA camera from Siliconfile |
546 | 565 | ||
547 | config VIDEO_NOON010PC30 | 566 | config VIDEO_NOON010PC30 |
548 | tristate "Siliconfile NOON010PC30 sensor support" | 567 | tristate "Siliconfile NOON010PC30 sensor support" |
549 | depends on I2C && VIDEO_V4L2 && EXPERIMENTAL && VIDEO_V4L2_SUBDEV_API | 568 | depends on I2C && VIDEO_V4L2 && EXPERIMENTAL && VIDEO_V4L2_SUBDEV_API |
569 | depends on MEDIA_CAMERA_SUPPORT | ||
550 | ---help--- | 570 | ---help--- |
551 | This driver supports NOON010PC30 CIF camera from Siliconfile | 571 | This driver supports NOON010PC30 CIF camera from Siliconfile |
552 | 572 | ||
@@ -554,6 +574,7 @@ source "drivers/media/video/m5mols/Kconfig" | |||
554 | 574 | ||
555 | config VIDEO_S5K6AA | 575 | config VIDEO_S5K6AA |
556 | tristate "Samsung S5K6AAFX sensor support" | 576 | tristate "Samsung S5K6AAFX sensor support" |
577 | depends on MEDIA_CAMERA_SUPPORT | ||
557 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API | 578 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API |
558 | ---help--- | 579 | ---help--- |
559 | This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M | 580 | This is a V4L2 sensor-level driver for Samsung S5K6AA(FX) 1.3M |
@@ -566,6 +587,7 @@ comment "Flash devices" | |||
566 | config VIDEO_ADP1653 | 587 | config VIDEO_ADP1653 |
567 | tristate "ADP1653 flash support" | 588 | tristate "ADP1653 flash support" |
568 | depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER | 589 | depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER |
590 | depends on MEDIA_CAMERA_SUPPORT | ||
569 | ---help--- | 591 | ---help--- |
570 | This is a driver for the ADP1653 flash controller. It is used for | 592 | This is a driver for the ADP1653 flash controller. It is used for |
571 | example in Nokia N900. | 593 | example in Nokia N900. |
@@ -573,6 +595,7 @@ config VIDEO_ADP1653 | |||
573 | config VIDEO_AS3645A | 595 | config VIDEO_AS3645A |
574 | tristate "AS3645A flash driver support" | 596 | tristate "AS3645A flash driver support" |
575 | depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER | 597 | depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER |
598 | depends on MEDIA_CAMERA_SUPPORT | ||
576 | ---help--- | 599 | ---help--- |
577 | This is a driver for the AS3645A and LM3555 flash controllers. It has | 600 | This is a driver for the AS3645A and LM3555 flash controllers. It has |
578 | build in control for flash, torch and indicator LEDs. | 601 | build in control for flash, torch and indicator LEDs. |
@@ -647,30 +670,14 @@ menuconfig V4L_USB_DRIVERS | |||
647 | depends on USB | 670 | depends on USB |
648 | default y | 671 | default y |
649 | 672 | ||
650 | if V4L_USB_DRIVERS | 673 | if V4L_USB_DRIVERS && MEDIA_CAMERA_SUPPORT |
651 | 674 | ||
652 | source "drivers/media/video/au0828/Kconfig" | 675 | comment "Webcam devices" |
653 | 676 | ||
654 | source "drivers/media/video/uvc/Kconfig" | 677 | source "drivers/media/video/uvc/Kconfig" |
655 | 678 | ||
656 | source "drivers/media/video/gspca/Kconfig" | 679 | source "drivers/media/video/gspca/Kconfig" |
657 | 680 | ||
658 | source "drivers/media/video/pvrusb2/Kconfig" | ||
659 | |||
660 | source "drivers/media/video/hdpvr/Kconfig" | ||
661 | |||
662 | source "drivers/media/video/em28xx/Kconfig" | ||
663 | |||
664 | source "drivers/media/video/tlg2300/Kconfig" | ||
665 | |||
666 | source "drivers/media/video/cx231xx/Kconfig" | ||
667 | |||
668 | source "drivers/media/video/tm6000/Kconfig" | ||
669 | |||
670 | source "drivers/media/video/usbvision/Kconfig" | ||
671 | |||
672 | source "drivers/media/video/sn9c102/Kconfig" | ||
673 | |||
674 | source "drivers/media/video/pwc/Kconfig" | 681 | source "drivers/media/video/pwc/Kconfig" |
675 | 682 | ||
676 | source "drivers/media/video/cpia2/Kconfig" | 683 | source "drivers/media/video/cpia2/Kconfig" |
@@ -711,15 +718,46 @@ config USB_S2255 | |||
711 | Say Y here if you want support for the Sensoray 2255 USB device. | 718 | Say Y here if you want support for the Sensoray 2255 USB device. |
712 | This driver can be compiled as a module, called s2255drv. | 719 | This driver can be compiled as a module, called s2255drv. |
713 | 720 | ||
721 | source "drivers/media/video/sn9c102/Kconfig" | ||
722 | |||
723 | endif # V4L_USB_DRIVERS && MEDIA_CAMERA_SUPPORT | ||
724 | |||
725 | if V4L_USB_DRIVERS | ||
726 | |||
727 | comment "Webcam and/or TV USB devices" | ||
728 | |||
729 | source "drivers/media/video/em28xx/Kconfig" | ||
730 | |||
731 | endif | ||
732 | |||
733 | if V4L_USB_DRIVERS && MEDIA_ANALOG_TV_SUPPORT | ||
734 | |||
735 | comment "TV USB devices" | ||
736 | |||
737 | source "drivers/media/video/au0828/Kconfig" | ||
738 | |||
739 | source "drivers/media/video/pvrusb2/Kconfig" | ||
740 | |||
741 | source "drivers/media/video/hdpvr/Kconfig" | ||
742 | |||
743 | source "drivers/media/video/tlg2300/Kconfig" | ||
744 | |||
745 | source "drivers/media/video/cx231xx/Kconfig" | ||
746 | |||
747 | source "drivers/media/video/tm6000/Kconfig" | ||
748 | |||
749 | source "drivers/media/video/usbvision/Kconfig" | ||
750 | |||
714 | endif # V4L_USB_DRIVERS | 751 | endif # V4L_USB_DRIVERS |
715 | 752 | ||
716 | # | 753 | # |
717 | # PCI drivers configuration | 754 | # PCI drivers configuration - No devices here are for webcams |
718 | # | 755 | # |
719 | 756 | ||
720 | menuconfig V4L_PCI_DRIVERS | 757 | menuconfig V4L_PCI_DRIVERS |
721 | bool "V4L PCI(e) devices" | 758 | bool "V4L PCI(e) devices" |
722 | depends on PCI | 759 | depends on PCI |
760 | depends on MEDIA_ANALOG_TV_SUPPORT | ||
723 | default y | 761 | default y |
724 | ---help--- | 762 | ---help--- |
725 | Say Y here to enable support for these PCI(e) drivers. | 763 | Say Y here to enable support for these PCI(e) drivers. |
@@ -814,11 +852,13 @@ endif # V4L_PCI_DRIVERS | |||
814 | 852 | ||
815 | # | 853 | # |
816 | # ISA & parallel port drivers configuration | 854 | # ISA & parallel port drivers configuration |
855 | # All devices here are webcam or grabber devices | ||
817 | # | 856 | # |
818 | 857 | ||
819 | menuconfig V4L_ISA_PARPORT_DRIVERS | 858 | menuconfig V4L_ISA_PARPORT_DRIVERS |
820 | bool "V4L ISA and parallel port devices" | 859 | bool "V4L ISA and parallel port devices" |
821 | depends on ISA || PARPORT | 860 | depends on ISA || PARPORT |
861 | depends on MEDIA_CAMERA_SUPPORT | ||
822 | default n | 862 | default n |
823 | ---help--- | 863 | ---help--- |
824 | Say Y here to enable support for these ISA and parallel port drivers. | 864 | Say Y here to enable support for these ISA and parallel port drivers. |
@@ -871,8 +911,13 @@ config VIDEO_W9966 | |||
871 | 911 | ||
872 | endif # V4L_ISA_PARPORT_DRIVERS | 912 | endif # V4L_ISA_PARPORT_DRIVERS |
873 | 913 | ||
914 | # | ||
915 | # Platform drivers | ||
916 | # All drivers here are currently for webcam support | ||
917 | |||
874 | menuconfig V4L_PLATFORM_DRIVERS | 918 | menuconfig V4L_PLATFORM_DRIVERS |
875 | bool "V4L platform devices" | 919 | bool "V4L platform devices" |
920 | depends on MEDIA_CAMERA_SUPPORT | ||
876 | default n | 921 | default n |
877 | ---help--- | 922 | ---help--- |
878 | Say Y here to enable support for platform-specific V4L drivers. | 923 | Say Y here to enable support for platform-specific V4L drivers. |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index d209de0e0ca8..b7da9faa3b0a 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -45,6 +45,7 @@ obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o | |||
45 | obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o | 45 | obj-$(CONFIG_VIDEO_ADV7180) += adv7180.o |
46 | obj-$(CONFIG_VIDEO_ADV7183) += adv7183.o | 46 | obj-$(CONFIG_VIDEO_ADV7183) += adv7183.o |
47 | obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o | 47 | obj-$(CONFIG_VIDEO_ADV7343) += adv7343.o |
48 | obj-$(CONFIG_VIDEO_ADV7393) += adv7393.o | ||
48 | obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o | 49 | obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o |
49 | obj-$(CONFIG_VIDEO_VS6624) += vs6624.o | 50 | obj-$(CONFIG_VIDEO_VS6624) += vs6624.o |
50 | obj-$(CONFIG_VIDEO_BT819) += bt819.o | 51 | obj-$(CONFIG_VIDEO_BT819) += bt819.o |
diff --git a/drivers/media/video/adv7393.c b/drivers/media/video/adv7393.c new file mode 100644 index 000000000000..3dc6098c7267 --- /dev/null +++ b/drivers/media/video/adv7393.c | |||
@@ -0,0 +1,487 @@ | |||
1 | /* | ||
2 | * adv7393 - ADV7393 Video Encoder Driver | ||
3 | * | ||
4 | * The encoder hardware does not support SECAM. | ||
5 | * | ||
6 | * Copyright (C) 2010-2012 ADVANSEE - http://www.advansee.com/ | ||
7 | * Benoît Thébaudeau <benoit.thebaudeau@advansee.com> | ||
8 | * | ||
9 | * Based on ADV7343 driver, | ||
10 | * | ||
11 | * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License as | ||
15 | * published by the Free Software Foundation version 2. | ||
16 | * | ||
17 | * This program is distributed .as is. WITHOUT ANY WARRANTY of any | ||
18 | * kind, whether express or implied; without even the implied warranty | ||
19 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/ctype.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/i2c.h> | ||
28 | #include <linux/device.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/module.h> | ||
31 | #include <linux/videodev2.h> | ||
32 | #include <linux/uaccess.h> | ||
33 | |||
34 | #include <media/adv7393.h> | ||
35 | #include <media/v4l2-device.h> | ||
36 | #include <media/v4l2-chip-ident.h> | ||
37 | #include <media/v4l2-ctrls.h> | ||
38 | |||
39 | #include "adv7393_regs.h" | ||
40 | |||
41 | MODULE_DESCRIPTION("ADV7393 video encoder driver"); | ||
42 | MODULE_LICENSE("GPL"); | ||
43 | |||
44 | static bool debug; | ||
45 | module_param(debug, bool, 0644); | ||
46 | MODULE_PARM_DESC(debug, "Debug level 0-1"); | ||
47 | |||
48 | struct adv7393_state { | ||
49 | struct v4l2_subdev sd; | ||
50 | struct v4l2_ctrl_handler hdl; | ||
51 | u8 reg00; | ||
52 | u8 reg01; | ||
53 | u8 reg02; | ||
54 | u8 reg35; | ||
55 | u8 reg80; | ||
56 | u8 reg82; | ||
57 | u32 output; | ||
58 | v4l2_std_id std; | ||
59 | }; | ||
60 | |||
61 | static inline struct adv7393_state *to_state(struct v4l2_subdev *sd) | ||
62 | { | ||
63 | return container_of(sd, struct adv7393_state, sd); | ||
64 | } | ||
65 | |||
66 | static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) | ||
67 | { | ||
68 | return &container_of(ctrl->handler, struct adv7393_state, hdl)->sd; | ||
69 | } | ||
70 | |||
71 | static inline int adv7393_write(struct v4l2_subdev *sd, u8 reg, u8 value) | ||
72 | { | ||
73 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
74 | |||
75 | return i2c_smbus_write_byte_data(client, reg, value); | ||
76 | } | ||
77 | |||
78 | static const u8 adv7393_init_reg_val[] = { | ||
79 | ADV7393_SOFT_RESET, ADV7393_SOFT_RESET_DEFAULT, | ||
80 | ADV7393_POWER_MODE_REG, ADV7393_POWER_MODE_REG_DEFAULT, | ||
81 | |||
82 | ADV7393_HD_MODE_REG1, ADV7393_HD_MODE_REG1_DEFAULT, | ||
83 | ADV7393_HD_MODE_REG2, ADV7393_HD_MODE_REG2_DEFAULT, | ||
84 | ADV7393_HD_MODE_REG3, ADV7393_HD_MODE_REG3_DEFAULT, | ||
85 | ADV7393_HD_MODE_REG4, ADV7393_HD_MODE_REG4_DEFAULT, | ||
86 | ADV7393_HD_MODE_REG5, ADV7393_HD_MODE_REG5_DEFAULT, | ||
87 | ADV7393_HD_MODE_REG6, ADV7393_HD_MODE_REG6_DEFAULT, | ||
88 | ADV7393_HD_MODE_REG7, ADV7393_HD_MODE_REG7_DEFAULT, | ||
89 | |||
90 | ADV7393_SD_MODE_REG1, ADV7393_SD_MODE_REG1_DEFAULT, | ||
91 | ADV7393_SD_MODE_REG2, ADV7393_SD_MODE_REG2_DEFAULT, | ||
92 | ADV7393_SD_MODE_REG3, ADV7393_SD_MODE_REG3_DEFAULT, | ||
93 | ADV7393_SD_MODE_REG4, ADV7393_SD_MODE_REG4_DEFAULT, | ||
94 | ADV7393_SD_MODE_REG5, ADV7393_SD_MODE_REG5_DEFAULT, | ||
95 | ADV7393_SD_MODE_REG6, ADV7393_SD_MODE_REG6_DEFAULT, | ||
96 | ADV7393_SD_MODE_REG7, ADV7393_SD_MODE_REG7_DEFAULT, | ||
97 | ADV7393_SD_MODE_REG8, ADV7393_SD_MODE_REG8_DEFAULT, | ||
98 | |||
99 | ADV7393_SD_TIMING_REG0, ADV7393_SD_TIMING_REG0_DEFAULT, | ||
100 | |||
101 | ADV7393_SD_HUE_ADJUST, ADV7393_SD_HUE_ADJUST_DEFAULT, | ||
102 | ADV7393_SD_CGMS_WSS0, ADV7393_SD_CGMS_WSS0_DEFAULT, | ||
103 | ADV7393_SD_BRIGHTNESS_WSS, ADV7393_SD_BRIGHTNESS_WSS_DEFAULT, | ||
104 | }; | ||
105 | |||
106 | /* | ||
107 | * 2^32 | ||
108 | * FSC(reg) = FSC (HZ) * -------- | ||
109 | * 27000000 | ||
110 | */ | ||
111 | static const struct adv7393_std_info stdinfo[] = { | ||
112 | { | ||
113 | /* FSC(Hz) = 4,433,618.75 Hz */ | ||
114 | SD_STD_NTSC, 705268427, V4L2_STD_NTSC_443, | ||
115 | }, { | ||
116 | /* FSC(Hz) = 3,579,545.45 Hz */ | ||
117 | SD_STD_NTSC, 569408542, V4L2_STD_NTSC, | ||
118 | }, { | ||
119 | /* FSC(Hz) = 3,575,611.00 Hz */ | ||
120 | SD_STD_PAL_M, 568782678, V4L2_STD_PAL_M, | ||
121 | }, { | ||
122 | /* FSC(Hz) = 3,582,056.00 Hz */ | ||
123 | SD_STD_PAL_N, 569807903, V4L2_STD_PAL_Nc, | ||
124 | }, { | ||
125 | /* FSC(Hz) = 4,433,618.75 Hz */ | ||
126 | SD_STD_PAL_N, 705268427, V4L2_STD_PAL_N, | ||
127 | }, { | ||
128 | /* FSC(Hz) = 4,433,618.75 Hz */ | ||
129 | SD_STD_PAL_M, 705268427, V4L2_STD_PAL_60, | ||
130 | }, { | ||
131 | /* FSC(Hz) = 4,433,618.75 Hz */ | ||
132 | SD_STD_PAL_BDGHI, 705268427, V4L2_STD_PAL, | ||
133 | }, | ||
134 | }; | ||
135 | |||
136 | static int adv7393_setstd(struct v4l2_subdev *sd, v4l2_std_id std) | ||
137 | { | ||
138 | struct adv7393_state *state = to_state(sd); | ||
139 | const struct adv7393_std_info *std_info; | ||
140 | int num_std; | ||
141 | u8 reg; | ||
142 | u32 val; | ||
143 | int err = 0; | ||
144 | int i; | ||
145 | |||
146 | num_std = ARRAY_SIZE(stdinfo); | ||
147 | |||
148 | for (i = 0; i < num_std; i++) { | ||
149 | if (stdinfo[i].stdid & std) | ||
150 | break; | ||
151 | } | ||
152 | |||
153 | if (i == num_std) { | ||
154 | v4l2_dbg(1, debug, sd, | ||
155 | "Invalid std or std is not supported: %llx\n", | ||
156 | (unsigned long long)std); | ||
157 | return -EINVAL; | ||
158 | } | ||
159 | |||
160 | std_info = &stdinfo[i]; | ||
161 | |||
162 | /* Set the standard */ | ||
163 | val = state->reg80 & ~SD_STD_MASK; | ||
164 | val |= std_info->standard_val3; | ||
165 | err = adv7393_write(sd, ADV7393_SD_MODE_REG1, val); | ||
166 | if (err < 0) | ||
167 | goto setstd_exit; | ||
168 | |||
169 | state->reg80 = val; | ||
170 | |||
171 | /* Configure the input mode register */ | ||
172 | val = state->reg01 & ~INPUT_MODE_MASK; | ||
173 | val |= SD_INPUT_MODE; | ||
174 | err = adv7393_write(sd, ADV7393_MODE_SELECT_REG, val); | ||
175 | if (err < 0) | ||
176 | goto setstd_exit; | ||
177 | |||
178 | state->reg01 = val; | ||
179 | |||
180 | /* Program the sub carrier frequency registers */ | ||
181 | val = std_info->fsc_val; | ||
182 | for (reg = ADV7393_FSC_REG0; reg <= ADV7393_FSC_REG3; reg++) { | ||
183 | err = adv7393_write(sd, reg, val); | ||
184 | if (err < 0) | ||
185 | goto setstd_exit; | ||
186 | val >>= 8; | ||
187 | } | ||
188 | |||
189 | val = state->reg82; | ||
190 | |||
191 | /* Pedestal settings */ | ||
192 | if (std & (V4L2_STD_NTSC | V4L2_STD_NTSC_443)) | ||
193 | val |= SD_PEDESTAL_EN; | ||
194 | else | ||
195 | val &= SD_PEDESTAL_DI; | ||
196 | |||
197 | err = adv7393_write(sd, ADV7393_SD_MODE_REG2, val); | ||
198 | if (err < 0) | ||
199 | goto setstd_exit; | ||
200 | |||
201 | state->reg82 = val; | ||
202 | |||
203 | setstd_exit: | ||
204 | if (err != 0) | ||
205 | v4l2_err(sd, "Error setting std, write failed\n"); | ||
206 | |||
207 | return err; | ||
208 | } | ||
209 | |||
210 | static int adv7393_setoutput(struct v4l2_subdev *sd, u32 output_type) | ||
211 | { | ||
212 | struct adv7393_state *state = to_state(sd); | ||
213 | u8 val; | ||
214 | int err = 0; | ||
215 | |||
216 | if (output_type > ADV7393_SVIDEO_ID) { | ||
217 | v4l2_dbg(1, debug, sd, | ||
218 | "Invalid output type or output type not supported:%d\n", | ||
219 | output_type); | ||
220 | return -EINVAL; | ||
221 | } | ||
222 | |||
223 | /* Enable Appropriate DAC */ | ||
224 | val = state->reg00 & 0x03; | ||
225 | |||
226 | if (output_type == ADV7393_COMPOSITE_ID) | ||
227 | val |= ADV7393_COMPOSITE_POWER_VALUE; | ||
228 | else if (output_type == ADV7393_COMPONENT_ID) | ||
229 | val |= ADV7393_COMPONENT_POWER_VALUE; | ||
230 | else | ||
231 | val |= ADV7393_SVIDEO_POWER_VALUE; | ||
232 | |||
233 | err = adv7393_write(sd, ADV7393_POWER_MODE_REG, val); | ||
234 | if (err < 0) | ||
235 | goto setoutput_exit; | ||
236 | |||
237 | state->reg00 = val; | ||
238 | |||
239 | /* Enable YUV output */ | ||
240 | val = state->reg02 | YUV_OUTPUT_SELECT; | ||
241 | err = adv7393_write(sd, ADV7393_MODE_REG0, val); | ||
242 | if (err < 0) | ||
243 | goto setoutput_exit; | ||
244 | |||
245 | state->reg02 = val; | ||
246 | |||
247 | /* configure SD DAC Output 1 bit */ | ||
248 | val = state->reg82; | ||
249 | if (output_type == ADV7393_COMPONENT_ID) | ||
250 | val &= SD_DAC_OUT1_DI; | ||
251 | else | ||
252 | val |= SD_DAC_OUT1_EN; | ||
253 | err = adv7393_write(sd, ADV7393_SD_MODE_REG2, val); | ||
254 | if (err < 0) | ||
255 | goto setoutput_exit; | ||
256 | |||
257 | state->reg82 = val; | ||
258 | |||
259 | /* configure ED/HD Color DAC Swap bit to zero */ | ||
260 | val = state->reg35 & HD_DAC_SWAP_DI; | ||
261 | err = adv7393_write(sd, ADV7393_HD_MODE_REG6, val); | ||
262 | if (err < 0) | ||
263 | goto setoutput_exit; | ||
264 | |||
265 | state->reg35 = val; | ||
266 | |||
267 | setoutput_exit: | ||
268 | if (err != 0) | ||
269 | v4l2_err(sd, "Error setting output, write failed\n"); | ||
270 | |||
271 | return err; | ||
272 | } | ||
273 | |||
274 | static int adv7393_log_status(struct v4l2_subdev *sd) | ||
275 | { | ||
276 | struct adv7393_state *state = to_state(sd); | ||
277 | |||
278 | v4l2_info(sd, "Standard: %llx\n", (unsigned long long)state->std); | ||
279 | v4l2_info(sd, "Output: %s\n", (state->output == 0) ? "Composite" : | ||
280 | ((state->output == 1) ? "Component" : "S-Video")); | ||
281 | return 0; | ||
282 | } | ||
283 | |||
284 | static int adv7393_s_ctrl(struct v4l2_ctrl *ctrl) | ||
285 | { | ||
286 | struct v4l2_subdev *sd = to_sd(ctrl); | ||
287 | |||
288 | switch (ctrl->id) { | ||
289 | case V4L2_CID_BRIGHTNESS: | ||
290 | return adv7393_write(sd, ADV7393_SD_BRIGHTNESS_WSS, | ||
291 | ctrl->val & SD_BRIGHTNESS_VALUE_MASK); | ||
292 | |||
293 | case V4L2_CID_HUE: | ||
294 | return adv7393_write(sd, ADV7393_SD_HUE_ADJUST, | ||
295 | ctrl->val - ADV7393_HUE_MIN); | ||
296 | |||
297 | case V4L2_CID_GAIN: | ||
298 | return adv7393_write(sd, ADV7393_DAC123_OUTPUT_LEVEL, | ||
299 | ctrl->val); | ||
300 | } | ||
301 | return -EINVAL; | ||
302 | } | ||
303 | |||
304 | static int adv7393_g_chip_ident(struct v4l2_subdev *sd, | ||
305 | struct v4l2_dbg_chip_ident *chip) | ||
306 | { | ||
307 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
308 | |||
309 | return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_ADV7393, 0); | ||
310 | } | ||
311 | |||
312 | static const struct v4l2_ctrl_ops adv7393_ctrl_ops = { | ||
313 | .s_ctrl = adv7393_s_ctrl, | ||
314 | }; | ||
315 | |||
316 | static const struct v4l2_subdev_core_ops adv7393_core_ops = { | ||
317 | .log_status = adv7393_log_status, | ||
318 | .g_chip_ident = adv7393_g_chip_ident, | ||
319 | .g_ext_ctrls = v4l2_subdev_g_ext_ctrls, | ||
320 | .try_ext_ctrls = v4l2_subdev_try_ext_ctrls, | ||
321 | .s_ext_ctrls = v4l2_subdev_s_ext_ctrls, | ||
322 | .g_ctrl = v4l2_subdev_g_ctrl, | ||
323 | .s_ctrl = v4l2_subdev_s_ctrl, | ||
324 | .queryctrl = v4l2_subdev_queryctrl, | ||
325 | .querymenu = v4l2_subdev_querymenu, | ||
326 | }; | ||
327 | |||
328 | static int adv7393_s_std_output(struct v4l2_subdev *sd, v4l2_std_id std) | ||
329 | { | ||
330 | struct adv7393_state *state = to_state(sd); | ||
331 | int err = 0; | ||
332 | |||
333 | if (state->std == std) | ||
334 | return 0; | ||
335 | |||
336 | err = adv7393_setstd(sd, std); | ||
337 | if (!err) | ||
338 | state->std = std; | ||
339 | |||
340 | return err; | ||
341 | } | ||
342 | |||
343 | static int adv7393_s_routing(struct v4l2_subdev *sd, | ||
344 | u32 input, u32 output, u32 config) | ||
345 | { | ||
346 | struct adv7393_state *state = to_state(sd); | ||
347 | int err = 0; | ||
348 | |||
349 | if (state->output == output) | ||
350 | return 0; | ||
351 | |||
352 | err = adv7393_setoutput(sd, output); | ||
353 | if (!err) | ||
354 | state->output = output; | ||
355 | |||
356 | return err; | ||
357 | } | ||
358 | |||
359 | static const struct v4l2_subdev_video_ops adv7393_video_ops = { | ||
360 | .s_std_output = adv7393_s_std_output, | ||
361 | .s_routing = adv7393_s_routing, | ||
362 | }; | ||
363 | |||
364 | static const struct v4l2_subdev_ops adv7393_ops = { | ||
365 | .core = &adv7393_core_ops, | ||
366 | .video = &adv7393_video_ops, | ||
367 | }; | ||
368 | |||
369 | static int adv7393_initialize(struct v4l2_subdev *sd) | ||
370 | { | ||
371 | struct adv7393_state *state = to_state(sd); | ||
372 | int err = 0; | ||
373 | int i; | ||
374 | |||
375 | for (i = 0; i < ARRAY_SIZE(adv7393_init_reg_val); i += 2) { | ||
376 | |||
377 | err = adv7393_write(sd, adv7393_init_reg_val[i], | ||
378 | adv7393_init_reg_val[i+1]); | ||
379 | if (err) { | ||
380 | v4l2_err(sd, "Error initializing\n"); | ||
381 | return err; | ||
382 | } | ||
383 | } | ||
384 | |||
385 | /* Configure for default video standard */ | ||
386 | err = adv7393_setoutput(sd, state->output); | ||
387 | if (err < 0) { | ||
388 | v4l2_err(sd, "Error setting output during init\n"); | ||
389 | return -EINVAL; | ||
390 | } | ||
391 | |||
392 | err = adv7393_setstd(sd, state->std); | ||
393 | if (err < 0) { | ||
394 | v4l2_err(sd, "Error setting std during init\n"); | ||
395 | return -EINVAL; | ||
396 | } | ||
397 | |||
398 | return err; | ||
399 | } | ||
400 | |||
401 | static int adv7393_probe(struct i2c_client *client, | ||
402 | const struct i2c_device_id *id) | ||
403 | { | ||
404 | struct adv7393_state *state; | ||
405 | int err; | ||
406 | |||
407 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
408 | return -ENODEV; | ||
409 | |||
410 | v4l_info(client, "chip found @ 0x%x (%s)\n", | ||
411 | client->addr << 1, client->adapter->name); | ||
412 | |||
413 | state = kzalloc(sizeof(struct adv7393_state), GFP_KERNEL); | ||
414 | if (state == NULL) | ||
415 | return -ENOMEM; | ||
416 | |||
417 | state->reg00 = ADV7393_POWER_MODE_REG_DEFAULT; | ||
418 | state->reg01 = 0x00; | ||
419 | state->reg02 = 0x20; | ||
420 | state->reg35 = ADV7393_HD_MODE_REG6_DEFAULT; | ||
421 | state->reg80 = ADV7393_SD_MODE_REG1_DEFAULT; | ||
422 | state->reg82 = ADV7393_SD_MODE_REG2_DEFAULT; | ||
423 | |||
424 | state->output = ADV7393_COMPOSITE_ID; | ||
425 | state->std = V4L2_STD_NTSC; | ||
426 | |||
427 | v4l2_i2c_subdev_init(&state->sd, client, &adv7393_ops); | ||
428 | |||
429 | v4l2_ctrl_handler_init(&state->hdl, 3); | ||
430 | v4l2_ctrl_new_std(&state->hdl, &adv7393_ctrl_ops, | ||
431 | V4L2_CID_BRIGHTNESS, ADV7393_BRIGHTNESS_MIN, | ||
432 | ADV7393_BRIGHTNESS_MAX, 1, | ||
433 | ADV7393_BRIGHTNESS_DEF); | ||
434 | v4l2_ctrl_new_std(&state->hdl, &adv7393_ctrl_ops, | ||
435 | V4L2_CID_HUE, ADV7393_HUE_MIN, | ||
436 | ADV7393_HUE_MAX, 1, | ||
437 | ADV7393_HUE_DEF); | ||
438 | v4l2_ctrl_new_std(&state->hdl, &adv7393_ctrl_ops, | ||
439 | V4L2_CID_GAIN, ADV7393_GAIN_MIN, | ||
440 | ADV7393_GAIN_MAX, 1, | ||
441 | ADV7393_GAIN_DEF); | ||
442 | state->sd.ctrl_handler = &state->hdl; | ||
443 | if (state->hdl.error) { | ||
444 | int err = state->hdl.error; | ||
445 | |||
446 | v4l2_ctrl_handler_free(&state->hdl); | ||
447 | kfree(state); | ||
448 | return err; | ||
449 | } | ||
450 | v4l2_ctrl_handler_setup(&state->hdl); | ||
451 | |||
452 | err = adv7393_initialize(&state->sd); | ||
453 | if (err) { | ||
454 | v4l2_ctrl_handler_free(&state->hdl); | ||
455 | kfree(state); | ||
456 | } | ||
457 | return err; | ||
458 | } | ||
459 | |||
460 | static int adv7393_remove(struct i2c_client *client) | ||
461 | { | ||
462 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | ||
463 | struct adv7393_state *state = to_state(sd); | ||
464 | |||
465 | v4l2_device_unregister_subdev(sd); | ||
466 | v4l2_ctrl_handler_free(&state->hdl); | ||
467 | kfree(state); | ||
468 | |||
469 | return 0; | ||
470 | } | ||
471 | |||
472 | static const struct i2c_device_id adv7393_id[] = { | ||
473 | {"adv7393", 0}, | ||
474 | {}, | ||
475 | }; | ||
476 | MODULE_DEVICE_TABLE(i2c, adv7393_id); | ||
477 | |||
478 | static struct i2c_driver adv7393_driver = { | ||
479 | .driver = { | ||
480 | .owner = THIS_MODULE, | ||
481 | .name = "adv7393", | ||
482 | }, | ||
483 | .probe = adv7393_probe, | ||
484 | .remove = adv7393_remove, | ||
485 | .id_table = adv7393_id, | ||
486 | }; | ||
487 | module_i2c_driver(adv7393_driver); | ||
diff --git a/drivers/media/video/adv7393_regs.h b/drivers/media/video/adv7393_regs.h new file mode 100644 index 000000000000..78968330f0be --- /dev/null +++ b/drivers/media/video/adv7393_regs.h | |||
@@ -0,0 +1,188 @@ | |||
1 | /* | ||
2 | * ADV7393 encoder related structure and register definitions | ||
3 | * | ||
4 | * Copyright (C) 2010-2012 ADVANSEE - http://www.advansee.com/ | ||
5 | * Benoît Thébaudeau <benoit.thebaudeau@advansee.com> | ||
6 | * | ||
7 | * Based on ADV7343 driver, | ||
8 | * | ||
9 | * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License as | ||
13 | * published by the Free Software Foundation version 2. | ||
14 | * | ||
15 | * This program is distributed .as is. WITHOUT ANY WARRANTY of any | ||
16 | * kind, whether express or implied; without even the implied warranty | ||
17 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | */ | ||
20 | |||
21 | #ifndef ADV7393_REGS_H | ||
22 | #define ADV7393_REGS_H | ||
23 | |||
24 | struct adv7393_std_info { | ||
25 | u32 standard_val3; | ||
26 | u32 fsc_val; | ||
27 | v4l2_std_id stdid; | ||
28 | }; | ||
29 | |||
30 | /* Register offset macros */ | ||
31 | #define ADV7393_POWER_MODE_REG (0x00) | ||
32 | #define ADV7393_MODE_SELECT_REG (0x01) | ||
33 | #define ADV7393_MODE_REG0 (0x02) | ||
34 | |||
35 | #define ADV7393_DAC123_OUTPUT_LEVEL (0x0B) | ||
36 | |||
37 | #define ADV7393_SOFT_RESET (0x17) | ||
38 | |||
39 | #define ADV7393_HD_MODE_REG1 (0x30) | ||
40 | #define ADV7393_HD_MODE_REG2 (0x31) | ||
41 | #define ADV7393_HD_MODE_REG3 (0x32) | ||
42 | #define ADV7393_HD_MODE_REG4 (0x33) | ||
43 | #define ADV7393_HD_MODE_REG5 (0x34) | ||
44 | #define ADV7393_HD_MODE_REG6 (0x35) | ||
45 | |||
46 | #define ADV7393_HD_MODE_REG7 (0x39) | ||
47 | |||
48 | #define ADV7393_SD_MODE_REG1 (0x80) | ||
49 | #define ADV7393_SD_MODE_REG2 (0x82) | ||
50 | #define ADV7393_SD_MODE_REG3 (0x83) | ||
51 | #define ADV7393_SD_MODE_REG4 (0x84) | ||
52 | #define ADV7393_SD_MODE_REG5 (0x86) | ||
53 | #define ADV7393_SD_MODE_REG6 (0x87) | ||
54 | #define ADV7393_SD_MODE_REG7 (0x88) | ||
55 | #define ADV7393_SD_MODE_REG8 (0x89) | ||
56 | |||
57 | #define ADV7393_SD_TIMING_REG0 (0x8A) | ||
58 | |||
59 | #define ADV7393_FSC_REG0 (0x8C) | ||
60 | #define ADV7393_FSC_REG1 (0x8D) | ||
61 | #define ADV7393_FSC_REG2 (0x8E) | ||
62 | #define ADV7393_FSC_REG3 (0x8F) | ||
63 | |||
64 | #define ADV7393_SD_CGMS_WSS0 (0x99) | ||
65 | |||
66 | #define ADV7393_SD_HUE_ADJUST (0xA0) | ||
67 | #define ADV7393_SD_BRIGHTNESS_WSS (0xA1) | ||
68 | |||
69 | /* Default values for the registers */ | ||
70 | #define ADV7393_POWER_MODE_REG_DEFAULT (0x10) | ||
71 | #define ADV7393_HD_MODE_REG1_DEFAULT (0x3C) /* Changed Default | ||
72 | 720p EAV/SAV code*/ | ||
73 | #define ADV7393_HD_MODE_REG2_DEFAULT (0x01) /* Changed Pixel data | ||
74 | valid */ | ||
75 | #define ADV7393_HD_MODE_REG3_DEFAULT (0x00) /* Color delay 0 clks */ | ||
76 | #define ADV7393_HD_MODE_REG4_DEFAULT (0xEC) /* Changed */ | ||
77 | #define ADV7393_HD_MODE_REG5_DEFAULT (0x08) | ||
78 | #define ADV7393_HD_MODE_REG6_DEFAULT (0x00) | ||
79 | #define ADV7393_HD_MODE_REG7_DEFAULT (0x00) | ||
80 | #define ADV7393_SOFT_RESET_DEFAULT (0x02) | ||
81 | #define ADV7393_COMPOSITE_POWER_VALUE (0x10) | ||
82 | #define ADV7393_COMPONENT_POWER_VALUE (0x1C) | ||
83 | #define ADV7393_SVIDEO_POWER_VALUE (0x0C) | ||
84 | #define ADV7393_SD_HUE_ADJUST_DEFAULT (0x80) | ||
85 | #define ADV7393_SD_BRIGHTNESS_WSS_DEFAULT (0x00) | ||
86 | |||
87 | #define ADV7393_SD_CGMS_WSS0_DEFAULT (0x10) | ||
88 | |||
89 | #define ADV7393_SD_MODE_REG1_DEFAULT (0x10) | ||
90 | #define ADV7393_SD_MODE_REG2_DEFAULT (0xC9) | ||
91 | #define ADV7393_SD_MODE_REG3_DEFAULT (0x00) | ||
92 | #define ADV7393_SD_MODE_REG4_DEFAULT (0x00) | ||
93 | #define ADV7393_SD_MODE_REG5_DEFAULT (0x02) | ||
94 | #define ADV7393_SD_MODE_REG6_DEFAULT (0x8C) | ||
95 | #define ADV7393_SD_MODE_REG7_DEFAULT (0x14) | ||
96 | #define ADV7393_SD_MODE_REG8_DEFAULT (0x00) | ||
97 | |||
98 | #define ADV7393_SD_TIMING_REG0_DEFAULT (0x0C) | ||
99 | |||
100 | /* Bit masks for Mode Select Register */ | ||
101 | #define INPUT_MODE_MASK (0x70) | ||
102 | #define SD_INPUT_MODE (0x00) | ||
103 | #define HD_720P_INPUT_MODE (0x10) | ||
104 | #define HD_1080I_INPUT_MODE (0x10) | ||
105 | |||
106 | /* Bit masks for Mode Register 0 */ | ||
107 | #define TEST_PATTERN_BLACK_BAR_EN (0x04) | ||
108 | #define YUV_OUTPUT_SELECT (0x20) | ||
109 | #define RGB_OUTPUT_SELECT (0xDF) | ||
110 | |||
111 | /* Bit masks for SD brightness/WSS */ | ||
112 | #define SD_BRIGHTNESS_VALUE_MASK (0x7F) | ||
113 | #define SD_BLANK_WSS_DATA_MASK (0x80) | ||
114 | |||
115 | /* Bit masks for soft reset register */ | ||
116 | #define SOFT_RESET (0x02) | ||
117 | |||
118 | /* Bit masks for HD Mode Register 1 */ | ||
119 | #define OUTPUT_STD_MASK (0x03) | ||
120 | #define OUTPUT_STD_SHIFT (0) | ||
121 | #define OUTPUT_STD_EIA0_2 (0x00) | ||
122 | #define OUTPUT_STD_EIA0_1 (0x01) | ||
123 | #define OUTPUT_STD_FULL (0x02) | ||
124 | #define EMBEDDED_SYNC (0x04) | ||
125 | #define EXTERNAL_SYNC (0xFB) | ||
126 | #define STD_MODE_MASK (0x1F) | ||
127 | #define STD_MODE_SHIFT (3) | ||
128 | #define STD_MODE_720P (0x05) | ||
129 | #define STD_MODE_720P_25 (0x08) | ||
130 | #define STD_MODE_720P_30 (0x07) | ||
131 | #define STD_MODE_720P_50 (0x06) | ||
132 | #define STD_MODE_1080I (0x0D) | ||
133 | #define STD_MODE_1080I_25 (0x0E) | ||
134 | #define STD_MODE_1080P_24 (0x11) | ||
135 | #define STD_MODE_1080P_25 (0x10) | ||
136 | #define STD_MODE_1080P_30 (0x0F) | ||
137 | #define STD_MODE_525P (0x00) | ||
138 | #define STD_MODE_625P (0x03) | ||
139 | |||
140 | /* Bit masks for SD Mode Register 1 */ | ||
141 | #define SD_STD_MASK (0x03) | ||
142 | #define SD_STD_NTSC (0x00) | ||
143 | #define SD_STD_PAL_BDGHI (0x01) | ||
144 | #define SD_STD_PAL_M (0x02) | ||
145 | #define SD_STD_PAL_N (0x03) | ||
146 | #define SD_LUMA_FLTR_MASK (0x07) | ||
147 | #define SD_LUMA_FLTR_SHIFT (2) | ||
148 | #define SD_CHROMA_FLTR_MASK (0x07) | ||
149 | #define SD_CHROMA_FLTR_SHIFT (5) | ||
150 | |||
151 | /* Bit masks for SD Mode Register 2 */ | ||
152 | #define SD_PRPB_SSAF_EN (0x01) | ||
153 | #define SD_PRPB_SSAF_DI (0xFE) | ||
154 | #define SD_DAC_OUT1_EN (0x02) | ||
155 | #define SD_DAC_OUT1_DI (0xFD) | ||
156 | #define SD_PEDESTAL_EN (0x08) | ||
157 | #define SD_PEDESTAL_DI (0xF7) | ||
158 | #define SD_SQUARE_PIXEL_EN (0x10) | ||
159 | #define SD_SQUARE_PIXEL_DI (0xEF) | ||
160 | #define SD_PIXEL_DATA_VALID (0x40) | ||
161 | #define SD_ACTIVE_EDGE_EN (0x80) | ||
162 | #define SD_ACTIVE_EDGE_DI (0x7F) | ||
163 | |||
164 | /* Bit masks for HD Mode Register 6 */ | ||
165 | #define HD_PRPB_SYNC_EN (0x04) | ||
166 | #define HD_PRPB_SYNC_DI (0xFB) | ||
167 | #define HD_DAC_SWAP_EN (0x08) | ||
168 | #define HD_DAC_SWAP_DI (0xF7) | ||
169 | #define HD_GAMMA_CURVE_A (0xEF) | ||
170 | #define HD_GAMMA_CURVE_B (0x10) | ||
171 | #define HD_GAMMA_EN (0x20) | ||
172 | #define HD_GAMMA_DI (0xDF) | ||
173 | #define HD_ADPT_FLTR_MODEA (0xBF) | ||
174 | #define HD_ADPT_FLTR_MODEB (0x40) | ||
175 | #define HD_ADPT_FLTR_EN (0x80) | ||
176 | #define HD_ADPT_FLTR_DI (0x7F) | ||
177 | |||
178 | #define ADV7393_BRIGHTNESS_MAX (63) | ||
179 | #define ADV7393_BRIGHTNESS_MIN (-64) | ||
180 | #define ADV7393_BRIGHTNESS_DEF (0) | ||
181 | #define ADV7393_HUE_MAX (127) | ||
182 | #define ADV7393_HUE_MIN (-128) | ||
183 | #define ADV7393_HUE_DEF (0) | ||
184 | #define ADV7393_GAIN_MAX (64) | ||
185 | #define ADV7393_GAIN_MIN (-64) | ||
186 | #define ADV7393_GAIN_DEF (0) | ||
187 | |||
188 | #endif | ||
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c index 856ab962cd63..5f3a00c2c4f6 100644 --- a/drivers/media/video/bt8xx/bttv-cards.c +++ b/drivers/media/video/bt8xx/bttv-cards.c | |||
@@ -676,6 +676,7 @@ struct tvcard bttv_tvcards[] = { | |||
676 | .tuner_type = UNSET, | 676 | .tuner_type = UNSET, |
677 | .tuner_addr = ADDR_UNSET, | 677 | .tuner_addr = ADDR_UNSET, |
678 | .has_remote = 1, | 678 | .has_remote = 1, |
679 | .has_radio = 1, /* not every card has radio */ | ||
679 | }, | 680 | }, |
680 | [BTTV_BOARD_VOBIS_BOOSTAR] = { | 681 | [BTTV_BOARD_VOBIS_BOOSTAR] = { |
681 | .name = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar", | 682 | .name = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar", |
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index ff7a589d8e0f..b58ff87db771 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -558,12 +558,6 @@ static const struct bttv_format formats[] = { | |||
558 | .depth = 16, | 558 | .depth = 16, |
559 | .flags = FORMAT_FLAGS_PACKED, | 559 | .flags = FORMAT_FLAGS_PACKED, |
560 | },{ | 560 | },{ |
561 | .name = "4:2:2, packed, YUYV", | ||
562 | .fourcc = V4L2_PIX_FMT_YUYV, | ||
563 | .btformat = BT848_COLOR_FMT_YUY2, | ||
564 | .depth = 16, | ||
565 | .flags = FORMAT_FLAGS_PACKED, | ||
566 | },{ | ||
567 | .name = "4:2:2, packed, UYVY", | 561 | .name = "4:2:2, packed, UYVY", |
568 | .fourcc = V4L2_PIX_FMT_UYVY, | 562 | .fourcc = V4L2_PIX_FMT_UYVY, |
569 | .btformat = BT848_COLOR_FMT_YUY2, | 563 | .btformat = BT848_COLOR_FMT_YUY2, |
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c index 55e92902a76c..a62a7b739991 100644 --- a/drivers/media/video/cpia2/cpia2_v4l.c +++ b/drivers/media/video/cpia2/cpia2_v4l.c | |||
@@ -932,7 +932,7 @@ static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | |||
932 | buf->sequence = cam->buffers[buf->index].seq; | 932 | buf->sequence = cam->buffers[buf->index].seq; |
933 | buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; | 933 | buf->m.offset = cam->buffers[buf->index].data - cam->frame_buffer; |
934 | buf->length = cam->frame_size; | 934 | buf->length = cam->frame_size; |
935 | buf->input = 0; | 935 | buf->reserved2 = 0; |
936 | buf->reserved = 0; | 936 | buf->reserved = 0; |
937 | memset(&buf->timecode, 0, sizeof(buf->timecode)); | 937 | memset(&buf->timecode, 0, sizeof(buf->timecode)); |
938 | 938 | ||
diff --git a/drivers/media/video/cs8420.h b/drivers/media/video/cs8420.h deleted file mode 100644 index 621c0c6678ea..000000000000 --- a/drivers/media/video/cs8420.h +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | /* cs8420.h - cs8420 initializations | ||
2 | Copyright (C) 1999 Nathan Laredo (laredo@gnu.org) | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | |||
18 | */ | ||
19 | #ifndef __CS8420_H__ | ||
20 | #define __CS8420_H__ | ||
21 | |||
22 | /* Initialization Sequence */ | ||
23 | |||
24 | static __u8 init8420[] = { | ||
25 | 1, 0x01, 2, 0x02, 3, 0x00, 4, 0x46, | ||
26 | 5, 0x24, 6, 0x84, 18, 0x18, 19, 0x13, | ||
27 | }; | ||
28 | |||
29 | #define INIT8420LEN (sizeof(init8420)/2) | ||
30 | |||
31 | static __u8 mode8420pro[] = { /* professional output mode */ | ||
32 | 32, 0xa1, 33, 0x00, 34, 0x00, 35, 0x00, | ||
33 | 36, 0x00, 37, 0x00, 38, 0x00, 39, 0x00, | ||
34 | 40, 0x00, 41, 0x00, 42, 0x00, 43, 0x00, | ||
35 | 44, 0x00, 45, 0x00, 46, 0x00, 47, 0x00, | ||
36 | 48, 0x00, 49, 0x00, 50, 0x00, 51, 0x00, | ||
37 | 52, 0x00, 53, 0x00, 54, 0x00, 55, 0x00, | ||
38 | }; | ||
39 | #define MODE8420LEN (sizeof(mode8420pro)/2) | ||
40 | |||
41 | static __u8 mode8420con[] = { /* consumer output mode */ | ||
42 | 32, 0x20, 33, 0x00, 34, 0x00, 35, 0x48, | ||
43 | 36, 0x00, 37, 0x00, 38, 0x00, 39, 0x00, | ||
44 | 40, 0x00, 41, 0x00, 42, 0x00, 43, 0x00, | ||
45 | 44, 0x00, 45, 0x00, 46, 0x00, 47, 0x00, | ||
46 | 48, 0x00, 49, 0x00, 50, 0x00, 51, 0x00, | ||
47 | 52, 0x00, 53, 0x00, 54, 0x00, 55, 0x00, | ||
48 | }; | ||
49 | |||
50 | #endif | ||
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c index 35fde4e931f5..e9912db3b496 100644 --- a/drivers/media/video/cx18/cx18-ioctl.c +++ b/drivers/media/video/cx18/cx18-ioctl.c | |||
@@ -1142,24 +1142,6 @@ static long cx18_default(struct file *file, void *fh, bool valid_prio, | |||
1142 | return 0; | 1142 | return 0; |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd, | ||
1146 | unsigned long arg) | ||
1147 | { | ||
1148 | struct video_device *vfd = video_devdata(filp); | ||
1149 | struct cx18_open_id *id = file2id(filp); | ||
1150 | struct cx18 *cx = id->cx; | ||
1151 | long res; | ||
1152 | |||
1153 | mutex_lock(&cx->serialize_lock); | ||
1154 | |||
1155 | if (cx18_debug & CX18_DBGFLG_IOCTL) | ||
1156 | vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; | ||
1157 | res = video_ioctl2(filp, cmd, arg); | ||
1158 | vfd->debug = 0; | ||
1159 | mutex_unlock(&cx->serialize_lock); | ||
1160 | return res; | ||
1161 | } | ||
1162 | |||
1163 | static const struct v4l2_ioctl_ops cx18_ioctl_ops = { | 1145 | static const struct v4l2_ioctl_ops cx18_ioctl_ops = { |
1164 | .vidioc_querycap = cx18_querycap, | 1146 | .vidioc_querycap = cx18_querycap, |
1165 | .vidioc_s_audio = cx18_s_audio, | 1147 | .vidioc_s_audio = cx18_s_audio, |
diff --git a/drivers/media/video/cx18/cx18-ioctl.h b/drivers/media/video/cx18/cx18-ioctl.h index dcb2559ad520..2f9dd591ee0f 100644 --- a/drivers/media/video/cx18/cx18-ioctl.h +++ b/drivers/media/video/cx18/cx18-ioctl.h | |||
@@ -29,5 +29,3 @@ void cx18_set_funcs(struct video_device *vdev); | |||
29 | int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std); | 29 | int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std); |
30 | int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); | 30 | int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); |
31 | int cx18_s_input(struct file *file, void *fh, unsigned int inp); | 31 | int cx18_s_input(struct file *file, void *fh, unsigned int inp); |
32 | long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd, | ||
33 | unsigned long arg); | ||
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index 4185bcb80ca3..9d598ab88615 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c | |||
@@ -40,8 +40,7 @@ static struct v4l2_file_operations cx18_v4l2_enc_fops = { | |||
40 | .owner = THIS_MODULE, | 40 | .owner = THIS_MODULE, |
41 | .read = cx18_v4l2_read, | 41 | .read = cx18_v4l2_read, |
42 | .open = cx18_v4l2_open, | 42 | .open = cx18_v4l2_open, |
43 | /* FIXME change to video_ioctl2 if serialization lock can be removed */ | 43 | .unlocked_ioctl = video_ioctl2, |
44 | .unlocked_ioctl = cx18_v4l2_ioctl, | ||
45 | .release = cx18_v4l2_close, | 44 | .release = cx18_v4l2_close, |
46 | .poll = cx18_v4l2_enc_poll, | 45 | .poll = cx18_v4l2_enc_poll, |
47 | .mmap = cx18_v4l2_mmap, | 46 | .mmap = cx18_v4l2_mmap, |
@@ -376,6 +375,7 @@ static int cx18_prep_dev(struct cx18 *cx, int type) | |||
376 | s->video_dev->fops = &cx18_v4l2_enc_fops; | 375 | s->video_dev->fops = &cx18_v4l2_enc_fops; |
377 | s->video_dev->release = video_device_release; | 376 | s->video_dev->release = video_device_release; |
378 | s->video_dev->tvnorms = V4L2_STD_ALL; | 377 | s->video_dev->tvnorms = V4L2_STD_ALL; |
378 | s->video_dev->lock = &cx->serialize_lock; | ||
379 | set_bit(V4L2_FL_USE_FH_PRIO, &s->video_dev->flags); | 379 | set_bit(V4L2_FL_USE_FH_PRIO, &s->video_dev->flags); |
380 | cx18_set_funcs(s->video_dev); | 380 | cx18_set_funcs(s->video_dev); |
381 | return 0; | 381 | return 0; |
diff --git a/drivers/media/video/cx231xx/cx231xx-avcore.c b/drivers/media/video/cx231xx/cx231xx-avcore.c index b085a3c6dc04..447148eff958 100644 --- a/drivers/media/video/cx231xx/cx231xx-avcore.c +++ b/drivers/media/video/cx231xx/cx231xx-avcore.c | |||
@@ -89,7 +89,7 @@ void initGPIO(struct cx231xx *dev) | |||
89 | verve_read_byte(dev, 0x07, &val); | 89 | verve_read_byte(dev, 0x07, &val); |
90 | cx231xx_info(" verve_read_byte address0x07=0x%x\n", val); | 90 | cx231xx_info(" verve_read_byte address0x07=0x%x\n", val); |
91 | 91 | ||
92 | cx231xx_capture_start(dev, 1, 2); | 92 | cx231xx_capture_start(dev, 1, Vbi); |
93 | 93 | ||
94 | cx231xx_mode_register(dev, EP_MODE_SET, 0x0500FE00); | 94 | cx231xx_mode_register(dev, EP_MODE_SET, 0x0500FE00); |
95 | cx231xx_mode_register(dev, GBULK_BIT_EN, 0xFFFDFFFF); | 95 | cx231xx_mode_register(dev, GBULK_BIT_EN, 0xFFFDFFFF); |
@@ -99,7 +99,7 @@ void uninitGPIO(struct cx231xx *dev) | |||
99 | { | 99 | { |
100 | u8 value[4] = { 0, 0, 0, 0 }; | 100 | u8 value[4] = { 0, 0, 0, 0 }; |
101 | 101 | ||
102 | cx231xx_capture_start(dev, 0, 2); | 102 | cx231xx_capture_start(dev, 0, Vbi); |
103 | verve_write_byte(dev, 0x07, 0x14); | 103 | verve_write_byte(dev, 0x07, 0x14); |
104 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | 104 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, |
105 | 0x68, value, 4); | 105 | 0x68, value, 4); |
@@ -2516,29 +2516,29 @@ int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) | |||
2516 | 2516 | ||
2517 | if (dev->udev->speed == USB_SPEED_HIGH) { | 2517 | if (dev->udev->speed == USB_SPEED_HIGH) { |
2518 | switch (media_type) { | 2518 | switch (media_type) { |
2519 | case 81: /* audio */ | 2519 | case Audio: |
2520 | cx231xx_info("%s: Audio enter HANC\n", __func__); | 2520 | cx231xx_info("%s: Audio enter HANC\n", __func__); |
2521 | status = | 2521 | status = |
2522 | cx231xx_mode_register(dev, TS_MODE_REG, 0x9300); | 2522 | cx231xx_mode_register(dev, TS_MODE_REG, 0x9300); |
2523 | break; | 2523 | break; |
2524 | 2524 | ||
2525 | case 2: /* vbi */ | 2525 | case Vbi: |
2526 | cx231xx_info("%s: set vanc registers\n", __func__); | 2526 | cx231xx_info("%s: set vanc registers\n", __func__); |
2527 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x300); | 2527 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x300); |
2528 | break; | 2528 | break; |
2529 | 2529 | ||
2530 | case 3: /* sliced cc */ | 2530 | case Sliced_cc: |
2531 | cx231xx_info("%s: set hanc registers\n", __func__); | 2531 | cx231xx_info("%s: set hanc registers\n", __func__); |
2532 | status = | 2532 | status = |
2533 | cx231xx_mode_register(dev, TS_MODE_REG, 0x1300); | 2533 | cx231xx_mode_register(dev, TS_MODE_REG, 0x1300); |
2534 | break; | 2534 | break; |
2535 | 2535 | ||
2536 | case 0: /* video */ | 2536 | case Raw_Video: |
2537 | cx231xx_info("%s: set video registers\n", __func__); | 2537 | cx231xx_info("%s: set video registers\n", __func__); |
2538 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); | 2538 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); |
2539 | break; | 2539 | break; |
2540 | 2540 | ||
2541 | case 4: /* ts1 */ | 2541 | case TS1_serial_mode: |
2542 | cx231xx_info("%s: set ts1 registers", __func__); | 2542 | cx231xx_info("%s: set ts1 registers", __func__); |
2543 | 2543 | ||
2544 | if (dev->board.has_417) { | 2544 | if (dev->board.has_417) { |
@@ -2569,7 +2569,7 @@ int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) | |||
2569 | } | 2569 | } |
2570 | break; | 2570 | break; |
2571 | 2571 | ||
2572 | case 6: /* ts1 parallel mode */ | 2572 | case TS1_parallel_mode: |
2573 | cx231xx_info("%s: set ts1 parallel mode registers\n", | 2573 | cx231xx_info("%s: set ts1 parallel mode registers\n", |
2574 | __func__); | 2574 | __func__); |
2575 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); | 2575 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); |
@@ -2592,52 +2592,28 @@ int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type) | |||
2592 | /* get EP for media type */ | 2592 | /* get EP for media type */ |
2593 | pcb_config = (struct pcb_config *)&dev->current_pcb_config; | 2593 | pcb_config = (struct pcb_config *)&dev->current_pcb_config; |
2594 | 2594 | ||
2595 | if (pcb_config->config_num == 1) { | 2595 | if (pcb_config->config_num) { |
2596 | switch (media_type) { | 2596 | switch (media_type) { |
2597 | case 0: /* Video */ | 2597 | case Raw_Video: |
2598 | ep_mask = ENABLE_EP4; /* ep4 [00:1000] */ | 2598 | ep_mask = ENABLE_EP4; /* ep4 [00:1000] */ |
2599 | break; | 2599 | break; |
2600 | case 1: /* Audio */ | 2600 | case Audio: |
2601 | ep_mask = ENABLE_EP3; /* ep3 [00:0100] */ | 2601 | ep_mask = ENABLE_EP3; /* ep3 [00:0100] */ |
2602 | break; | 2602 | break; |
2603 | case 2: /* Vbi */ | 2603 | case Vbi: |
2604 | ep_mask = ENABLE_EP5; /* ep5 [01:0000] */ | 2604 | ep_mask = ENABLE_EP5; /* ep5 [01:0000] */ |
2605 | break; | 2605 | break; |
2606 | case 3: /* Sliced_cc */ | 2606 | case Sliced_cc: |
2607 | ep_mask = ENABLE_EP6; /* ep6 [10:0000] */ | 2607 | ep_mask = ENABLE_EP6; /* ep6 [10:0000] */ |
2608 | break; | 2608 | break; |
2609 | case 4: /* ts1 */ | 2609 | case TS1_serial_mode: |
2610 | case 6: /* ts1 parallel mode */ | 2610 | case TS1_parallel_mode: |
2611 | ep_mask = ENABLE_EP1; /* ep1 [00:0001] */ | 2611 | ep_mask = ENABLE_EP1; /* ep1 [00:0001] */ |
2612 | break; | 2612 | break; |
2613 | case 5: /* ts2 */ | 2613 | case TS2: |
2614 | ep_mask = ENABLE_EP2; /* ep2 [00:0010] */ | 2614 | ep_mask = ENABLE_EP2; /* ep2 [00:0010] */ |
2615 | break; | 2615 | break; |
2616 | } | 2616 | } |
2617 | |||
2618 | } else if (pcb_config->config_num > 1) { | ||
2619 | switch (media_type) { | ||
2620 | case 0: /* Video */ | ||
2621 | ep_mask = ENABLE_EP4; /* ep4 [00:1000] */ | ||
2622 | break; | ||
2623 | case 1: /* Audio */ | ||
2624 | ep_mask = ENABLE_EP3; /* ep3 [00:0100] */ | ||
2625 | break; | ||
2626 | case 2: /* Vbi */ | ||
2627 | ep_mask = ENABLE_EP5; /* ep5 [01:0000] */ | ||
2628 | break; | ||
2629 | case 3: /* Sliced_cc */ | ||
2630 | ep_mask = ENABLE_EP6; /* ep6 [10:0000] */ | ||
2631 | break; | ||
2632 | case 4: /* ts1 */ | ||
2633 | case 6: /* ts1 parallel mode */ | ||
2634 | ep_mask = ENABLE_EP1; /* ep1 [00:0001] */ | ||
2635 | break; | ||
2636 | case 5: /* ts2 */ | ||
2637 | ep_mask = ENABLE_EP2; /* ep2 [00:0010] */ | ||
2638 | break; | ||
2639 | } | ||
2640 | |||
2641 | } | 2617 | } |
2642 | 2618 | ||
2643 | if (start) { | 2619 | if (start) { |
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c index 8ed460d692e0..02d4d36735d3 100644 --- a/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/drivers/media/video/cx231xx/cx231xx-cards.c | |||
@@ -1023,7 +1023,6 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1023 | int nr = 0, ifnum; | 1023 | int nr = 0, ifnum; |
1024 | int i, isoc_pipe = 0; | 1024 | int i, isoc_pipe = 0; |
1025 | char *speed; | 1025 | char *speed; |
1026 | char descr[255] = ""; | ||
1027 | struct usb_interface_assoc_descriptor *assoc_desc; | 1026 | struct usb_interface_assoc_descriptor *assoc_desc; |
1028 | 1027 | ||
1029 | udev = usb_get_dev(interface_to_usbdev(interface)); | 1028 | udev = usb_get_dev(interface_to_usbdev(interface)); |
@@ -1098,20 +1097,10 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1098 | speed = "unknown"; | 1097 | speed = "unknown"; |
1099 | } | 1098 | } |
1100 | 1099 | ||
1101 | if (udev->manufacturer) | 1100 | cx231xx_info("New device %s %s @ %s Mbps " |
1102 | strlcpy(descr, udev->manufacturer, sizeof(descr)); | ||
1103 | |||
1104 | if (udev->product) { | ||
1105 | if (*descr) | ||
1106 | strlcat(descr, " ", sizeof(descr)); | ||
1107 | strlcat(descr, udev->product, sizeof(descr)); | ||
1108 | } | ||
1109 | if (*descr) | ||
1110 | strlcat(descr, " ", sizeof(descr)); | ||
1111 | |||
1112 | cx231xx_info("New device %s@ %s Mbps " | ||
1113 | "(%04x:%04x) with %d interfaces\n", | 1101 | "(%04x:%04x) with %d interfaces\n", |
1114 | descr, | 1102 | udev->manufacturer ? udev->manufacturer : "", |
1103 | udev->product ? udev->product : "", | ||
1115 | speed, | 1104 | speed, |
1116 | le16_to_cpu(udev->descriptor.idVendor), | 1105 | le16_to_cpu(udev->descriptor.idVendor), |
1117 | le16_to_cpu(udev->descriptor.idProduct), | 1106 | le16_to_cpu(udev->descriptor.idProduct), |
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c index 04bf6627d362..dfac6e34859f 100644 --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c | |||
@@ -585,13 +585,10 @@ static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol, | |||
585 | { | 585 | { |
586 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | 586 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); |
587 | struct cx88_core *core = chip->core; | 587 | struct cx88_core *core = chip->core; |
588 | struct v4l2_control client_ctl; | ||
589 | int left = value->value.integer.value[0]; | 588 | int left = value->value.integer.value[0]; |
590 | int right = value->value.integer.value[1]; | 589 | int right = value->value.integer.value[1]; |
591 | int v, b; | 590 | int v, b; |
592 | 591 | ||
593 | memset(&client_ctl, 0, sizeof(client_ctl)); | ||
594 | |||
595 | /* Pass volume & balance onto any WM8775 */ | 592 | /* Pass volume & balance onto any WM8775 */ |
596 | if (left >= right) { | 593 | if (left >= right) { |
597 | v = left << 10; | 594 | v = left << 10; |
@@ -600,13 +597,8 @@ static void snd_cx88_wm8775_volume_put(struct snd_kcontrol *kcontrol, | |||
600 | v = right << 10; | 597 | v = right << 10; |
601 | b = right ? 0xffff - (0x8000 * left) / right : 0x8000; | 598 | b = right ? 0xffff - (0x8000 * left) / right : 0x8000; |
602 | } | 599 | } |
603 | client_ctl.value = v; | 600 | wm8775_s_ctrl(core, V4L2_CID_AUDIO_VOLUME, v); |
604 | client_ctl.id = V4L2_CID_AUDIO_VOLUME; | 601 | wm8775_s_ctrl(core, V4L2_CID_AUDIO_BALANCE, b); |
605 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
606 | |||
607 | client_ctl.value = b; | ||
608 | client_ctl.id = V4L2_CID_AUDIO_BALANCE; | ||
609 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
610 | } | 602 | } |
611 | 603 | ||
612 | /* OK - TODO: test it */ | 604 | /* OK - TODO: test it */ |
@@ -687,14 +679,8 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol, | |||
687 | cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol); | 679 | cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol); |
688 | /* Pass mute onto any WM8775 */ | 680 | /* Pass mute onto any WM8775 */ |
689 | if ((core->board.audio_chip == V4L2_IDENT_WM8775) && | 681 | if ((core->board.audio_chip == V4L2_IDENT_WM8775) && |
690 | ((1<<6) == bit)) { | 682 | ((1<<6) == bit)) |
691 | struct v4l2_control client_ctl; | 683 | wm8775_s_ctrl(core, V4L2_CID_AUDIO_MUTE, 0 != (vol & bit)); |
692 | |||
693 | memset(&client_ctl, 0, sizeof(client_ctl)); | ||
694 | client_ctl.value = 0 != (vol & bit); | ||
695 | client_ctl.id = V4L2_CID_AUDIO_MUTE; | ||
696 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
697 | } | ||
698 | ret = 1; | 684 | ret = 1; |
699 | } | 685 | } |
700 | spin_unlock_irq(&chip->reg_lock); | 686 | spin_unlock_irq(&chip->reg_lock); |
@@ -724,13 +710,10 @@ static int snd_cx88_alc_get(struct snd_kcontrol *kcontrol, | |||
724 | { | 710 | { |
725 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); | 711 | snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); |
726 | struct cx88_core *core = chip->core; | 712 | struct cx88_core *core = chip->core; |
727 | struct v4l2_control client_ctl; | 713 | s32 val; |
728 | |||
729 | memset(&client_ctl, 0, sizeof(client_ctl)); | ||
730 | client_ctl.id = V4L2_CID_AUDIO_LOUDNESS; | ||
731 | call_hw(core, WM8775_GID, core, g_ctrl, &client_ctl); | ||
732 | value->value.integer.value[0] = client_ctl.value ? 1 : 0; | ||
733 | 714 | ||
715 | val = wm8775_g_ctrl(core, V4L2_CID_AUDIO_LOUDNESS); | ||
716 | value->value.integer.value[0] = val ? 1 : 0; | ||
734 | return 0; | 717 | return 0; |
735 | } | 718 | } |
736 | 719 | ||
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index ed7b2aa1ed83..843ffd9e533b 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/firmware.h> | 35 | #include <linux/firmware.h> |
36 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
37 | #include <media/v4l2-ioctl.h> | 37 | #include <media/v4l2-ioctl.h> |
38 | #include <media/v4l2-event.h> | ||
38 | #include <media/cx2341x.h> | 39 | #include <media/cx2341x.h> |
39 | 40 | ||
40 | #include "cx88.h" | 41 | #include "cx88.h" |
@@ -523,11 +524,10 @@ static void blackbird_codec_settings(struct cx8802_dev *dev) | |||
523 | blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, | 524 | blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, |
524 | dev->height, dev->width); | 525 | dev->height, dev->width); |
525 | 526 | ||
526 | dev->params.width = dev->width; | 527 | dev->cxhdl.width = dev->width; |
527 | dev->params.height = dev->height; | 528 | dev->cxhdl.height = dev->height; |
528 | dev->params.is_50hz = (dev->core->tvnorm & V4L2_STD_625_50) != 0; | 529 | cx2341x_handler_set_50hz(&dev->cxhdl, dev->core->tvnorm & V4L2_STD_625_50); |
529 | 530 | cx2341x_handler_setup(&dev->cxhdl); | |
530 | cx2341x_update(dev, blackbird_mbox_func, NULL, &dev->params); | ||
531 | } | 531 | } |
532 | 532 | ||
533 | static int blackbird_initialize_codec(struct cx8802_dev *dev) | 533 | static int blackbird_initialize_codec(struct cx8802_dev *dev) |
@@ -618,6 +618,8 @@ static int blackbird_start_codec(struct file *file, void *priv) | |||
618 | /* initialize the video input */ | 618 | /* initialize the video input */ |
619 | blackbird_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0); | 619 | blackbird_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0); |
620 | 620 | ||
621 | cx2341x_handler_set_busy(&dev->cxhdl, 1); | ||
622 | |||
621 | /* start capturing to the host interface */ | 623 | /* start capturing to the host interface */ |
622 | blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, | 624 | blackbird_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, |
623 | BLACKBIRD_MPEG_CAPTURE, | 625 | BLACKBIRD_MPEG_CAPTURE, |
@@ -636,6 +638,8 @@ static int blackbird_stop_codec(struct cx8802_dev *dev) | |||
636 | BLACKBIRD_RAW_BITS_NONE | 638 | BLACKBIRD_RAW_BITS_NONE |
637 | ); | 639 | ); |
638 | 640 | ||
641 | cx2341x_handler_set_busy(&dev->cxhdl, 0); | ||
642 | |||
639 | dev->mpeg_active = 0; | 643 | dev->mpeg_active = 0; |
640 | return 0; | 644 | return 0; |
641 | } | 645 | } |
@@ -685,58 +689,15 @@ static struct videobuf_queue_ops blackbird_qops = { | |||
685 | 689 | ||
686 | /* ------------------------------------------------------------------ */ | 690 | /* ------------------------------------------------------------------ */ |
687 | 691 | ||
688 | static const u32 *ctrl_classes[] = { | 692 | static int vidioc_querycap(struct file *file, void *priv, |
689 | cx88_user_ctrls, | ||
690 | cx2341x_mpeg_ctrls, | ||
691 | NULL | ||
692 | }; | ||
693 | |||
694 | static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qctrl) | ||
695 | { | ||
696 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | ||
697 | if (qctrl->id == 0) | ||
698 | return -EINVAL; | ||
699 | |||
700 | /* Standard V4L2 controls */ | ||
701 | if (cx8800_ctrl_query(dev->core, qctrl) == 0) | ||
702 | return 0; | ||
703 | |||
704 | /* MPEG V4L2 controls */ | ||
705 | if (cx2341x_ctrl_query(&dev->params, qctrl)) | ||
706 | qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; | ||
707 | return 0; | ||
708 | } | ||
709 | |||
710 | /* ------------------------------------------------------------------ */ | ||
711 | /* IOCTL Handlers */ | ||
712 | |||
713 | static int vidioc_querymenu (struct file *file, void *priv, | ||
714 | struct v4l2_querymenu *qmenu) | ||
715 | { | ||
716 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | ||
717 | struct v4l2_queryctrl qctrl; | ||
718 | |||
719 | qctrl.id = qmenu->id; | ||
720 | blackbird_queryctrl(dev, &qctrl); | ||
721 | return v4l2_ctrl_query_menu(qmenu, &qctrl, | ||
722 | cx2341x_ctrl_get_menu(&dev->params, qmenu->id)); | ||
723 | } | ||
724 | |||
725 | static int vidioc_querycap (struct file *file, void *priv, | ||
726 | struct v4l2_capability *cap) | 693 | struct v4l2_capability *cap) |
727 | { | 694 | { |
728 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | 695 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; |
729 | struct cx88_core *core = dev->core; | 696 | struct cx88_core *core = dev->core; |
730 | 697 | ||
731 | strcpy(cap->driver, "cx88_blackbird"); | 698 | strcpy(cap->driver, "cx88_blackbird"); |
732 | strlcpy(cap->card, core->board.name, sizeof(cap->card)); | 699 | sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); |
733 | sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); | 700 | cx88_querycap(file, core, cap); |
734 | cap->capabilities = | ||
735 | V4L2_CAP_VIDEO_CAPTURE | | ||
736 | V4L2_CAP_READWRITE | | ||
737 | V4L2_CAP_STREAMING; | ||
738 | if (UNSET != core->board.tuner_type) | ||
739 | cap->capabilities |= V4L2_CAP_TUNER; | ||
740 | return 0; | 701 | return 0; |
741 | } | 702 | } |
742 | 703 | ||
@@ -748,6 +709,7 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, | |||
748 | 709 | ||
749 | strlcpy(f->description, "MPEG", sizeof(f->description)); | 710 | strlcpy(f->description, "MPEG", sizeof(f->description)); |
750 | f->pixelformat = V4L2_PIX_FMT_MPEG; | 711 | f->pixelformat = V4L2_PIX_FMT_MPEG; |
712 | f->flags = V4L2_FMT_FLAG_COMPRESSED; | ||
751 | return 0; | 713 | return 0; |
752 | } | 714 | } |
753 | 715 | ||
@@ -759,12 +721,12 @@ static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, | |||
759 | 721 | ||
760 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 722 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
761 | f->fmt.pix.bytesperline = 0; | 723 | f->fmt.pix.bytesperline = 0; |
762 | f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */ | 724 | f->fmt.pix.sizeimage = 188 * 4 * mpegbufs; /* 188 * 4 * 1024; */; |
763 | f->fmt.pix.colorspace = 0; | 725 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
764 | f->fmt.pix.width = dev->width; | 726 | f->fmt.pix.width = dev->width; |
765 | f->fmt.pix.height = dev->height; | 727 | f->fmt.pix.height = dev->height; |
766 | f->fmt.pix.field = fh->mpegq.field; | 728 | f->fmt.pix.field = fh->mpegq.field; |
767 | dprintk(0,"VIDIOC_G_FMT: w: %d, h: %d, f: %d\n", | 729 | dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n", |
768 | dev->width, dev->height, fh->mpegq.field ); | 730 | dev->width, dev->height, fh->mpegq.field ); |
769 | return 0; | 731 | return 0; |
770 | } | 732 | } |
@@ -777,9 +739,9 @@ static int vidioc_try_fmt_vid_cap (struct file *file, void *priv, | |||
777 | 739 | ||
778 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 740 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
779 | f->fmt.pix.bytesperline = 0; | 741 | f->fmt.pix.bytesperline = 0; |
780 | f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */; | 742 | f->fmt.pix.sizeimage = 188 * 4 * mpegbufs; /* 188 * 4 * 1024; */; |
781 | f->fmt.pix.colorspace = 0; | 743 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
782 | dprintk(0,"VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n", | 744 | dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n", |
783 | dev->width, dev->height, fh->mpegq.field ); | 745 | dev->width, dev->height, fh->mpegq.field ); |
784 | return 0; | 746 | return 0; |
785 | } | 747 | } |
@@ -793,15 +755,15 @@ static int vidioc_s_fmt_vid_cap (struct file *file, void *priv, | |||
793 | 755 | ||
794 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | 756 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; |
795 | f->fmt.pix.bytesperline = 0; | 757 | f->fmt.pix.bytesperline = 0; |
796 | f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; /* 188 * 4 * 1024; */; | 758 | f->fmt.pix.sizeimage = 188 * 4 * mpegbufs; /* 188 * 4 * 1024; */; |
797 | f->fmt.pix.colorspace = 0; | 759 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
798 | dev->width = f->fmt.pix.width; | 760 | dev->width = f->fmt.pix.width; |
799 | dev->height = f->fmt.pix.height; | 761 | dev->height = f->fmt.pix.height; |
800 | fh->mpegq.field = f->fmt.pix.field; | 762 | fh->mpegq.field = f->fmt.pix.field; |
801 | cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); | 763 | cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); |
802 | blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, | 764 | blackbird_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, |
803 | f->fmt.pix.height, f->fmt.pix.width); | 765 | f->fmt.pix.height, f->fmt.pix.width); |
804 | dprintk(0,"VIDIOC_S_FMT: w: %d, h: %d, f: %d\n", | 766 | dprintk(1, "VIDIOC_S_FMT: w: %d, h: %d, f: %d\n", |
805 | f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field ); | 767 | f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field ); |
806 | return 0; | 768 | return 0; |
807 | } | 769 | } |
@@ -834,60 +796,21 @@ static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p) | |||
834 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | 796 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) |
835 | { | 797 | { |
836 | struct cx8802_fh *fh = priv; | 798 | struct cx8802_fh *fh = priv; |
799 | struct cx8802_dev *dev = fh->dev; | ||
800 | |||
801 | if (!dev->mpeg_active) | ||
802 | blackbird_start_codec(file, fh); | ||
837 | return videobuf_streamon(&fh->mpegq); | 803 | return videobuf_streamon(&fh->mpegq); |
838 | } | 804 | } |
839 | 805 | ||
840 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | 806 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) |
841 | { | 807 | { |
842 | struct cx8802_fh *fh = priv; | 808 | struct cx8802_fh *fh = priv; |
843 | return videobuf_streamoff(&fh->mpegq); | 809 | struct cx8802_dev *dev = fh->dev; |
844 | } | ||
845 | |||
846 | static int vidioc_g_ext_ctrls (struct file *file, void *priv, | ||
847 | struct v4l2_ext_controls *f) | ||
848 | { | ||
849 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | ||
850 | |||
851 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
852 | return -EINVAL; | ||
853 | return cx2341x_ext_ctrls(&dev->params, 0, f, VIDIOC_G_EXT_CTRLS); | ||
854 | } | ||
855 | |||
856 | static int vidioc_s_ext_ctrls (struct file *file, void *priv, | ||
857 | struct v4l2_ext_controls *f) | ||
858 | { | ||
859 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | ||
860 | struct cx2341x_mpeg_params p; | ||
861 | int err; | ||
862 | |||
863 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
864 | return -EINVAL; | ||
865 | 810 | ||
866 | if (dev->mpeg_active) | 811 | if (dev->mpeg_active) |
867 | blackbird_stop_codec(dev); | 812 | blackbird_stop_codec(dev); |
868 | 813 | return videobuf_streamoff(&fh->mpegq); | |
869 | p = dev->params; | ||
870 | err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_S_EXT_CTRLS); | ||
871 | if (!err) { | ||
872 | err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p); | ||
873 | dev->params = p; | ||
874 | } | ||
875 | return err; | ||
876 | } | ||
877 | |||
878 | static int vidioc_try_ext_ctrls (struct file *file, void *priv, | ||
879 | struct v4l2_ext_controls *f) | ||
880 | { | ||
881 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | ||
882 | struct cx2341x_mpeg_params p; | ||
883 | int err; | ||
884 | |||
885 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
886 | return -EINVAL; | ||
887 | p = dev->params; | ||
888 | err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_TRY_EXT_CTRLS); | ||
889 | |||
890 | return err; | ||
891 | } | 814 | } |
892 | 815 | ||
893 | static int vidioc_s_frequency (struct file *file, void *priv, | 816 | static int vidioc_s_frequency (struct file *file, void *priv, |
@@ -897,6 +820,10 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
897 | struct cx8802_dev *dev = fh->dev; | 820 | struct cx8802_dev *dev = fh->dev; |
898 | struct cx88_core *core = dev->core; | 821 | struct cx88_core *core = dev->core; |
899 | 822 | ||
823 | if (unlikely(UNSET == core->board.tuner_type)) | ||
824 | return -EINVAL; | ||
825 | if (unlikely(f->tuner != 0)) | ||
826 | return -EINVAL; | ||
900 | if (dev->mpeg_active) | 827 | if (dev->mpeg_active) |
901 | blackbird_stop_codec(dev); | 828 | blackbird_stop_codec(dev); |
902 | 829 | ||
@@ -914,29 +841,11 @@ static int vidioc_log_status (struct file *file, void *priv) | |||
914 | char name[32 + 2]; | 841 | char name[32 + 2]; |
915 | 842 | ||
916 | snprintf(name, sizeof(name), "%s/2", core->name); | 843 | snprintf(name, sizeof(name), "%s/2", core->name); |
917 | printk("%s/2: ============ START LOG STATUS ============\n", | ||
918 | core->name); | ||
919 | call_all(core, core, log_status); | 844 | call_all(core, core, log_status); |
920 | cx2341x_log_status(&dev->params, name); | 845 | v4l2_ctrl_handler_log_status(&dev->cxhdl.hdl, name); |
921 | printk("%s/2: ============= END LOG STATUS =============\n", | ||
922 | core->name); | ||
923 | return 0; | 846 | return 0; |
924 | } | 847 | } |
925 | 848 | ||
926 | static int vidioc_queryctrl (struct file *file, void *priv, | ||
927 | struct v4l2_queryctrl *qctrl) | ||
928 | { | ||
929 | struct cx8802_dev *dev = ((struct cx8802_fh *)priv)->dev; | ||
930 | |||
931 | if (blackbird_queryctrl(dev, qctrl) == 0) | ||
932 | return 0; | ||
933 | |||
934 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | ||
935 | if (unlikely(qctrl->id == 0)) | ||
936 | return -EINVAL; | ||
937 | return cx8800_ctrl_query(dev->core, qctrl); | ||
938 | } | ||
939 | |||
940 | static int vidioc_enum_input (struct file *file, void *priv, | 849 | static int vidioc_enum_input (struct file *file, void *priv, |
941 | struct v4l2_input *i) | 850 | struct v4l2_input *i) |
942 | { | 851 | { |
@@ -944,22 +853,6 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
944 | return cx88_enum_input (core,i); | 853 | return cx88_enum_input (core,i); |
945 | } | 854 | } |
946 | 855 | ||
947 | static int vidioc_g_ctrl (struct file *file, void *priv, | ||
948 | struct v4l2_control *ctl) | ||
949 | { | ||
950 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | ||
951 | return | ||
952 | cx88_get_control(core,ctl); | ||
953 | } | ||
954 | |||
955 | static int vidioc_s_ctrl (struct file *file, void *priv, | ||
956 | struct v4l2_control *ctl) | ||
957 | { | ||
958 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | ||
959 | return | ||
960 | cx88_set_control(core,ctl); | ||
961 | } | ||
962 | |||
963 | static int vidioc_g_frequency (struct file *file, void *priv, | 856 | static int vidioc_g_frequency (struct file *file, void *priv, |
964 | struct v4l2_frequency *f) | 857 | struct v4l2_frequency *f) |
965 | { | 858 | { |
@@ -968,8 +861,9 @@ static int vidioc_g_frequency (struct file *file, void *priv, | |||
968 | 861 | ||
969 | if (unlikely(UNSET == core->board.tuner_type)) | 862 | if (unlikely(UNSET == core->board.tuner_type)) |
970 | return -EINVAL; | 863 | return -EINVAL; |
864 | if (unlikely(f->tuner != 0)) | ||
865 | return -EINVAL; | ||
971 | 866 | ||
972 | f->type = V4L2_TUNER_ANALOG_TV; | ||
973 | f->frequency = core->freq; | 867 | f->frequency = core->freq; |
974 | call_all(core, tuner, g_frequency, f); | 868 | call_all(core, tuner, g_frequency, f); |
975 | 869 | ||
@@ -990,6 +884,8 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int i) | |||
990 | 884 | ||
991 | if (i >= 4) | 885 | if (i >= 4) |
992 | return -EINVAL; | 886 | return -EINVAL; |
887 | if (0 == INPUT(i).type) | ||
888 | return -EINVAL; | ||
993 | 889 | ||
994 | mutex_lock(&core->lock); | 890 | mutex_lock(&core->lock); |
995 | cx88_newstation(core); | 891 | cx88_newstation(core); |
@@ -1010,9 +906,9 @@ static int vidioc_g_tuner (struct file *file, void *priv, | |||
1010 | return -EINVAL; | 906 | return -EINVAL; |
1011 | 907 | ||
1012 | strcpy(t->name, "Television"); | 908 | strcpy(t->name, "Television"); |
1013 | t->type = V4L2_TUNER_ANALOG_TV; | ||
1014 | t->capability = V4L2_TUNER_CAP_NORM; | 909 | t->capability = V4L2_TUNER_CAP_NORM; |
1015 | t->rangehigh = 0xffffffffUL; | 910 | t->rangehigh = 0xffffffffUL; |
911 | call_all(core, tuner, g_tuner, t); | ||
1016 | 912 | ||
1017 | cx88_get_stereo(core ,t); | 913 | cx88_get_stereo(core ,t); |
1018 | reg = cx_read(MO_DEVICE_STATUS); | 914 | reg = cx_read(MO_DEVICE_STATUS); |
@@ -1034,6 +930,14 @@ static int vidioc_s_tuner (struct file *file, void *priv, | |||
1034 | return 0; | 930 | return 0; |
1035 | } | 931 | } |
1036 | 932 | ||
933 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm) | ||
934 | { | ||
935 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | ||
936 | |||
937 | *tvnorm = core->tvnorm; | ||
938 | return 0; | ||
939 | } | ||
940 | |||
1037 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | 941 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) |
1038 | { | 942 | { |
1039 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; | 943 | struct cx88_core *core = ((struct cx8802_fh *)priv)->dev->core; |
@@ -1087,6 +991,7 @@ static int mpeg_open(struct file *file) | |||
1087 | mutex_unlock(&dev->core->lock); | 991 | mutex_unlock(&dev->core->lock); |
1088 | return -ENOMEM; | 992 | return -ENOMEM; |
1089 | } | 993 | } |
994 | v4l2_fh_init(&fh->fh, vdev); | ||
1090 | file->private_data = fh; | 995 | file->private_data = fh; |
1091 | fh->dev = dev; | 996 | fh->dev = dev; |
1092 | 997 | ||
@@ -1103,6 +1008,7 @@ static int mpeg_open(struct file *file) | |||
1103 | 1008 | ||
1104 | dev->core->mpeg_users++; | 1009 | dev->core->mpeg_users++; |
1105 | mutex_unlock(&dev->core->lock); | 1010 | mutex_unlock(&dev->core->lock); |
1011 | v4l2_fh_add(&fh->fh); | ||
1106 | return 0; | 1012 | return 0; |
1107 | } | 1013 | } |
1108 | 1014 | ||
@@ -1123,6 +1029,8 @@ static int mpeg_release(struct file *file) | |||
1123 | 1029 | ||
1124 | videobuf_mmap_free(&fh->mpegq); | 1030 | videobuf_mmap_free(&fh->mpegq); |
1125 | 1031 | ||
1032 | v4l2_fh_del(&fh->fh); | ||
1033 | v4l2_fh_exit(&fh->fh); | ||
1126 | file->private_data = NULL; | 1034 | file->private_data = NULL; |
1127 | kfree(fh); | 1035 | kfree(fh); |
1128 | 1036 | ||
@@ -1155,13 +1063,14 @@ mpeg_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | |||
1155 | static unsigned int | 1063 | static unsigned int |
1156 | mpeg_poll(struct file *file, struct poll_table_struct *wait) | 1064 | mpeg_poll(struct file *file, struct poll_table_struct *wait) |
1157 | { | 1065 | { |
1066 | unsigned long req_events = poll_requested_events(wait); | ||
1158 | struct cx8802_fh *fh = file->private_data; | 1067 | struct cx8802_fh *fh = file->private_data; |
1159 | struct cx8802_dev *dev = fh->dev; | 1068 | struct cx8802_dev *dev = fh->dev; |
1160 | 1069 | ||
1161 | if (!dev->mpeg_active) | 1070 | if (!dev->mpeg_active && (req_events & (POLLIN | POLLRDNORM))) |
1162 | blackbird_start_codec(file, fh); | 1071 | blackbird_start_codec(file, fh); |
1163 | 1072 | ||
1164 | return videobuf_poll_stream(file, &fh->mpegq, wait); | 1073 | return v4l2_ctrl_poll(file, wait) | videobuf_poll_stream(file, &fh->mpegq, wait); |
1165 | } | 1074 | } |
1166 | 1075 | ||
1167 | static int | 1076 | static int |
@@ -1180,11 +1089,10 @@ static const struct v4l2_file_operations mpeg_fops = | |||
1180 | .read = mpeg_read, | 1089 | .read = mpeg_read, |
1181 | .poll = mpeg_poll, | 1090 | .poll = mpeg_poll, |
1182 | .mmap = mpeg_mmap, | 1091 | .mmap = mpeg_mmap, |
1183 | .ioctl = video_ioctl2, | 1092 | .unlocked_ioctl = video_ioctl2, |
1184 | }; | 1093 | }; |
1185 | 1094 | ||
1186 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { | 1095 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { |
1187 | .vidioc_querymenu = vidioc_querymenu, | ||
1188 | .vidioc_querycap = vidioc_querycap, | 1096 | .vidioc_querycap = vidioc_querycap, |
1189 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, | 1097 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, |
1190 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | 1098 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, |
@@ -1196,21 +1104,18 @@ static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { | |||
1196 | .vidioc_dqbuf = vidioc_dqbuf, | 1104 | .vidioc_dqbuf = vidioc_dqbuf, |
1197 | .vidioc_streamon = vidioc_streamon, | 1105 | .vidioc_streamon = vidioc_streamon, |
1198 | .vidioc_streamoff = vidioc_streamoff, | 1106 | .vidioc_streamoff = vidioc_streamoff, |
1199 | .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, | ||
1200 | .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, | ||
1201 | .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, | ||
1202 | .vidioc_s_frequency = vidioc_s_frequency, | 1107 | .vidioc_s_frequency = vidioc_s_frequency, |
1203 | .vidioc_log_status = vidioc_log_status, | 1108 | .vidioc_log_status = vidioc_log_status, |
1204 | .vidioc_queryctrl = vidioc_queryctrl, | ||
1205 | .vidioc_enum_input = vidioc_enum_input, | 1109 | .vidioc_enum_input = vidioc_enum_input, |
1206 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
1207 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
1208 | .vidioc_g_frequency = vidioc_g_frequency, | 1110 | .vidioc_g_frequency = vidioc_g_frequency, |
1209 | .vidioc_g_input = vidioc_g_input, | 1111 | .vidioc_g_input = vidioc_g_input, |
1210 | .vidioc_s_input = vidioc_s_input, | 1112 | .vidioc_s_input = vidioc_s_input, |
1211 | .vidioc_g_tuner = vidioc_g_tuner, | 1113 | .vidioc_g_tuner = vidioc_g_tuner, |
1212 | .vidioc_s_tuner = vidioc_s_tuner, | 1114 | .vidioc_s_tuner = vidioc_s_tuner, |
1115 | .vidioc_g_std = vidioc_g_std, | ||
1213 | .vidioc_s_std = vidioc_s_std, | 1116 | .vidioc_s_std = vidioc_s_std, |
1117 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
1118 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
1214 | }; | 1119 | }; |
1215 | 1120 | ||
1216 | static struct video_device cx8802_mpeg_template = { | 1121 | static struct video_device cx8802_mpeg_template = { |
@@ -1218,7 +1123,6 @@ static struct video_device cx8802_mpeg_template = { | |||
1218 | .fops = &mpeg_fops, | 1123 | .fops = &mpeg_fops, |
1219 | .ioctl_ops = &mpeg_ioctl_ops, | 1124 | .ioctl_ops = &mpeg_ioctl_ops, |
1220 | .tvnorms = CX88_NORMS, | 1125 | .tvnorms = CX88_NORMS, |
1221 | .current_norm = V4L2_STD_NTSC_M, | ||
1222 | }; | 1126 | }; |
1223 | 1127 | ||
1224 | /* ------------------------------------------------------------------ */ | 1128 | /* ------------------------------------------------------------------ */ |
@@ -1286,6 +1190,7 @@ static int blackbird_register_video(struct cx8802_dev *dev) | |||
1286 | 1190 | ||
1287 | dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci, | 1191 | dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci, |
1288 | &cx8802_mpeg_template,"mpeg"); | 1192 | &cx8802_mpeg_template,"mpeg"); |
1193 | dev->mpeg_dev->ctrl_handler = &dev->cxhdl.hdl; | ||
1289 | video_set_drvdata(dev->mpeg_dev, dev); | 1194 | video_set_drvdata(dev->mpeg_dev, dev); |
1290 | err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1); | 1195 | err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1); |
1291 | if (err < 0) { | 1196 | if (err < 0) { |
@@ -1318,17 +1223,20 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) | |||
1318 | goto fail_core; | 1223 | goto fail_core; |
1319 | 1224 | ||
1320 | dev->width = 720; | 1225 | dev->width = 720; |
1321 | dev->height = 576; | ||
1322 | cx2341x_fill_defaults(&dev->params); | ||
1323 | dev->params.port = CX2341X_PORT_STREAMING; | ||
1324 | |||
1325 | cx8802_mpeg_template.current_norm = core->tvnorm; | ||
1326 | |||
1327 | if (core->tvnorm & V4L2_STD_525_60) { | 1226 | if (core->tvnorm & V4L2_STD_525_60) { |
1328 | dev->height = 480; | 1227 | dev->height = 480; |
1329 | } else { | 1228 | } else { |
1330 | dev->height = 576; | 1229 | dev->height = 576; |
1331 | } | 1230 | } |
1231 | dev->cxhdl.port = CX2341X_PORT_STREAMING; | ||
1232 | dev->cxhdl.width = dev->width; | ||
1233 | dev->cxhdl.height = dev->height; | ||
1234 | dev->cxhdl.func = blackbird_mbox_func; | ||
1235 | dev->cxhdl.priv = dev; | ||
1236 | err = cx2341x_handler_init(&dev->cxhdl, 36); | ||
1237 | if (err) | ||
1238 | goto fail_core; | ||
1239 | v4l2_ctrl_add_handler(&dev->cxhdl.hdl, &core->video_hdl); | ||
1332 | 1240 | ||
1333 | /* blackbird stuff */ | 1241 | /* blackbird stuff */ |
1334 | printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n", | 1242 | printk("%s/2: cx23416 based mpeg encoder (blackbird reference design)\n", |
@@ -1336,12 +1244,14 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) | |||
1336 | host_setup(dev->core); | 1244 | host_setup(dev->core); |
1337 | 1245 | ||
1338 | blackbird_initialize_codec(dev); | 1246 | blackbird_initialize_codec(dev); |
1339 | blackbird_register_video(dev); | ||
1340 | 1247 | ||
1341 | /* initial device configuration: needed ? */ | 1248 | /* initial device configuration: needed ? */ |
1342 | // init_controls(core); | 1249 | // init_controls(core); |
1343 | cx88_set_tvnorm(core,core->tvnorm); | 1250 | cx88_set_tvnorm(core,core->tvnorm); |
1344 | cx88_video_mux(core,0); | 1251 | cx88_video_mux(core,0); |
1252 | cx2341x_handler_set_50hz(&dev->cxhdl, dev->height == 576); | ||
1253 | cx2341x_handler_setup(&dev->cxhdl); | ||
1254 | blackbird_register_video(dev); | ||
1345 | 1255 | ||
1346 | return 0; | 1256 | return 0; |
1347 | 1257 | ||
@@ -1351,8 +1261,12 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) | |||
1351 | 1261 | ||
1352 | static int cx8802_blackbird_remove(struct cx8802_driver *drv) | 1262 | static int cx8802_blackbird_remove(struct cx8802_driver *drv) |
1353 | { | 1263 | { |
1264 | struct cx88_core *core = drv->core; | ||
1265 | struct cx8802_dev *dev = core->dvbdev; | ||
1266 | |||
1354 | /* blackbird */ | 1267 | /* blackbird */ |
1355 | blackbird_unregister_video(drv->core->dvbdev); | 1268 | blackbird_unregister_video(drv->core->dvbdev); |
1269 | v4l2_ctrl_handler_free(&dev->cxhdl.hdl); | ||
1356 | 1270 | ||
1357 | return 0; | 1271 | return 0; |
1358 | } | 1272 | } |
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index cbd5d119a2c6..4e9d4f722960 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c | |||
@@ -3693,7 +3693,22 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
3693 | return NULL; | 3693 | return NULL; |
3694 | } | 3694 | } |
3695 | 3695 | ||
3696 | if (v4l2_ctrl_handler_init(&core->video_hdl, 13)) { | ||
3697 | v4l2_device_unregister(&core->v4l2_dev); | ||
3698 | kfree(core); | ||
3699 | return NULL; | ||
3700 | } | ||
3701 | |||
3702 | if (v4l2_ctrl_handler_init(&core->audio_hdl, 13)) { | ||
3703 | v4l2_ctrl_handler_free(&core->video_hdl); | ||
3704 | v4l2_device_unregister(&core->v4l2_dev); | ||
3705 | kfree(core); | ||
3706 | return NULL; | ||
3707 | } | ||
3708 | |||
3696 | if (0 != cx88_get_resources(core, pci)) { | 3709 | if (0 != cx88_get_resources(core, pci)) { |
3710 | v4l2_ctrl_handler_free(&core->video_hdl); | ||
3711 | v4l2_ctrl_handler_free(&core->audio_hdl); | ||
3697 | v4l2_device_unregister(&core->v4l2_dev); | 3712 | v4l2_device_unregister(&core->v4l2_dev); |
3698 | kfree(core); | 3713 | kfree(core); |
3699 | return NULL; | 3714 | return NULL; |
@@ -3706,6 +3721,11 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
3706 | core->bmmio = (u8 __iomem *)core->lmmio; | 3721 | core->bmmio = (u8 __iomem *)core->lmmio; |
3707 | 3722 | ||
3708 | if (core->lmmio == NULL) { | 3723 | if (core->lmmio == NULL) { |
3724 | release_mem_region(pci_resource_start(pci, 0), | ||
3725 | pci_resource_len(pci, 0)); | ||
3726 | v4l2_ctrl_handler_free(&core->video_hdl); | ||
3727 | v4l2_ctrl_handler_free(&core->audio_hdl); | ||
3728 | v4l2_device_unregister(&core->v4l2_dev); | ||
3709 | kfree(core); | 3729 | kfree(core); |
3710 | return NULL; | 3730 | return NULL; |
3711 | } | 3731 | } |
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index fbfdd8067937..e81c735f012a 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c | |||
@@ -1012,6 +1012,9 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) | |||
1012 | // tell i2c chips | 1012 | // tell i2c chips |
1013 | call_all(core, core, s_std, norm); | 1013 | call_all(core, core, s_std, norm); |
1014 | 1014 | ||
1015 | /* The chroma_agc control should be inaccessible if the video format is SECAM */ | ||
1016 | v4l2_ctrl_grab(core->chroma_agc, cxiformat == VideoFormatSECAM); | ||
1017 | |||
1015 | // done | 1018 | // done |
1016 | return 0; | 1019 | return 0; |
1017 | } | 1020 | } |
@@ -1030,10 +1033,10 @@ struct video_device *cx88_vdev_init(struct cx88_core *core, | |||
1030 | return NULL; | 1033 | return NULL; |
1031 | *vfd = *template_; | 1034 | *vfd = *template_; |
1032 | vfd->v4l2_dev = &core->v4l2_dev; | 1035 | vfd->v4l2_dev = &core->v4l2_dev; |
1033 | vfd->parent = &pci->dev; | ||
1034 | vfd->release = video_device_release; | 1036 | vfd->release = video_device_release; |
1035 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", | 1037 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", |
1036 | core->name, type, core->board.name); | 1038 | core->name, type, core->board.name); |
1039 | set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | ||
1037 | return vfd; | 1040 | return vfd; |
1038 | } | 1041 | } |
1039 | 1042 | ||
@@ -1086,6 +1089,8 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci) | |||
1086 | iounmap(core->lmmio); | 1089 | iounmap(core->lmmio); |
1087 | cx88_devcount--; | 1090 | cx88_devcount--; |
1088 | mutex_unlock(&devlist); | 1091 | mutex_unlock(&devlist); |
1092 | v4l2_ctrl_handler_free(&core->video_hdl); | ||
1093 | v4l2_ctrl_handler_free(&core->audio_hdl); | ||
1089 | v4l2_device_unregister(&core->v4l2_dev); | 1094 | v4l2_device_unregister(&core->v4l2_dev); |
1090 | kfree(core); | 1095 | kfree(core); |
1091 | } | 1096 | } |
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 921c56d115d6..f6fcc7e763ab 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include "cx88.h" | 40 | #include "cx88.h" |
41 | #include <media/v4l2-common.h> | 41 | #include <media/v4l2-common.h> |
42 | #include <media/v4l2-ioctl.h> | 42 | #include <media/v4l2-ioctl.h> |
43 | #include <media/v4l2-event.h> | ||
43 | #include <media/wm8775.h> | 44 | #include <media/wm8775.h> |
44 | 45 | ||
45 | MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); | 46 | MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards"); |
@@ -155,219 +156,147 @@ static const struct cx8800_fmt* format_by_fourcc(unsigned int fourcc) | |||
155 | 156 | ||
156 | /* ------------------------------------------------------------------- */ | 157 | /* ------------------------------------------------------------------- */ |
157 | 158 | ||
158 | static const struct v4l2_queryctrl no_ctl = { | 159 | struct cx88_ctrl { |
159 | .name = "42", | 160 | /* control information */ |
160 | .flags = V4L2_CTRL_FLAG_DISABLED, | 161 | u32 id; |
162 | s32 minimum; | ||
163 | s32 maximum; | ||
164 | u32 step; | ||
165 | s32 default_value; | ||
166 | |||
167 | /* control register information */ | ||
168 | u32 off; | ||
169 | u32 reg; | ||
170 | u32 sreg; | ||
171 | u32 mask; | ||
172 | u32 shift; | ||
161 | }; | 173 | }; |
162 | 174 | ||
163 | static const struct cx88_ctrl cx8800_ctls[] = { | 175 | static const struct cx88_ctrl cx8800_vid_ctls[] = { |
164 | /* --- video --- */ | 176 | /* --- video --- */ |
165 | { | 177 | { |
166 | .v = { | 178 | .id = V4L2_CID_BRIGHTNESS, |
167 | .id = V4L2_CID_BRIGHTNESS, | 179 | .minimum = 0x00, |
168 | .name = "Brightness", | 180 | .maximum = 0xff, |
169 | .minimum = 0x00, | 181 | .step = 1, |
170 | .maximum = 0xff, | 182 | .default_value = 0x7f, |
171 | .step = 1, | 183 | .off = 128, |
172 | .default_value = 0x7f, | 184 | .reg = MO_CONTR_BRIGHT, |
173 | .type = V4L2_CTRL_TYPE_INTEGER, | 185 | .mask = 0x00ff, |
174 | }, | 186 | .shift = 0, |
175 | .off = 128, | ||
176 | .reg = MO_CONTR_BRIGHT, | ||
177 | .mask = 0x00ff, | ||
178 | .shift = 0, | ||
179 | },{ | 187 | },{ |
180 | .v = { | 188 | .id = V4L2_CID_CONTRAST, |
181 | .id = V4L2_CID_CONTRAST, | 189 | .minimum = 0, |
182 | .name = "Contrast", | 190 | .maximum = 0xff, |
183 | .minimum = 0, | 191 | .step = 1, |
184 | .maximum = 0xff, | 192 | .default_value = 0x3f, |
185 | .step = 1, | 193 | .off = 0, |
186 | .default_value = 0x3f, | 194 | .reg = MO_CONTR_BRIGHT, |
187 | .type = V4L2_CTRL_TYPE_INTEGER, | 195 | .mask = 0xff00, |
188 | }, | 196 | .shift = 8, |
189 | .off = 0, | ||
190 | .reg = MO_CONTR_BRIGHT, | ||
191 | .mask = 0xff00, | ||
192 | .shift = 8, | ||
193 | },{ | 197 | },{ |
194 | .v = { | 198 | .id = V4L2_CID_HUE, |
195 | .id = V4L2_CID_HUE, | 199 | .minimum = 0, |
196 | .name = "Hue", | 200 | .maximum = 0xff, |
197 | .minimum = 0, | 201 | .step = 1, |
198 | .maximum = 0xff, | 202 | .default_value = 0x7f, |
199 | .step = 1, | 203 | .off = 128, |
200 | .default_value = 0x7f, | 204 | .reg = MO_HUE, |
201 | .type = V4L2_CTRL_TYPE_INTEGER, | 205 | .mask = 0x00ff, |
202 | }, | 206 | .shift = 0, |
203 | .off = 128, | ||
204 | .reg = MO_HUE, | ||
205 | .mask = 0x00ff, | ||
206 | .shift = 0, | ||
207 | },{ | 207 | },{ |
208 | /* strictly, this only describes only U saturation. | 208 | /* strictly, this only describes only U saturation. |
209 | * V saturation is handled specially through code. | 209 | * V saturation is handled specially through code. |
210 | */ | 210 | */ |
211 | .v = { | 211 | .id = V4L2_CID_SATURATION, |
212 | .id = V4L2_CID_SATURATION, | 212 | .minimum = 0, |
213 | .name = "Saturation", | 213 | .maximum = 0xff, |
214 | .minimum = 0, | 214 | .step = 1, |
215 | .maximum = 0xff, | 215 | .default_value = 0x7f, |
216 | .step = 1, | 216 | .off = 0, |
217 | .default_value = 0x7f, | 217 | .reg = MO_UV_SATURATION, |
218 | .type = V4L2_CTRL_TYPE_INTEGER, | 218 | .mask = 0x00ff, |
219 | }, | 219 | .shift = 0, |
220 | .off = 0, | ||
221 | .reg = MO_UV_SATURATION, | ||
222 | .mask = 0x00ff, | ||
223 | .shift = 0, | ||
224 | }, { | 220 | }, { |
225 | .v = { | 221 | .id = V4L2_CID_SHARPNESS, |
226 | .id = V4L2_CID_SHARPNESS, | 222 | .minimum = 0, |
227 | .name = "Sharpness", | 223 | .maximum = 4, |
228 | .minimum = 0, | 224 | .step = 1, |
229 | .maximum = 4, | 225 | .default_value = 0x0, |
230 | .step = 1, | 226 | .off = 0, |
231 | .default_value = 0x0, | ||
232 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
233 | }, | ||
234 | .off = 0, | ||
235 | /* NOTE: the value is converted and written to both even | 227 | /* NOTE: the value is converted and written to both even |
236 | and odd registers in the code */ | 228 | and odd registers in the code */ |
237 | .reg = MO_FILTER_ODD, | 229 | .reg = MO_FILTER_ODD, |
238 | .mask = 7 << 7, | 230 | .mask = 7 << 7, |
239 | .shift = 7, | 231 | .shift = 7, |
240 | }, { | 232 | }, { |
241 | .v = { | 233 | .id = V4L2_CID_CHROMA_AGC, |
242 | .id = V4L2_CID_CHROMA_AGC, | 234 | .minimum = 0, |
243 | .name = "Chroma AGC", | 235 | .maximum = 1, |
244 | .minimum = 0, | 236 | .default_value = 0x1, |
245 | .maximum = 1, | 237 | .reg = MO_INPUT_FORMAT, |
246 | .default_value = 0x1, | 238 | .mask = 1 << 10, |
247 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 239 | .shift = 10, |
248 | }, | ||
249 | .reg = MO_INPUT_FORMAT, | ||
250 | .mask = 1 << 10, | ||
251 | .shift = 10, | ||
252 | }, { | 240 | }, { |
253 | .v = { | 241 | .id = V4L2_CID_COLOR_KILLER, |
254 | .id = V4L2_CID_COLOR_KILLER, | 242 | .minimum = 0, |
255 | .name = "Color killer", | 243 | .maximum = 1, |
256 | .minimum = 0, | 244 | .default_value = 0x1, |
257 | .maximum = 1, | 245 | .reg = MO_INPUT_FORMAT, |
258 | .default_value = 0x1, | 246 | .mask = 1 << 9, |
259 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 247 | .shift = 9, |
260 | }, | ||
261 | .reg = MO_INPUT_FORMAT, | ||
262 | .mask = 1 << 9, | ||
263 | .shift = 9, | ||
264 | }, { | 248 | }, { |
265 | .v = { | 249 | .id = V4L2_CID_BAND_STOP_FILTER, |
266 | .id = V4L2_CID_BAND_STOP_FILTER, | 250 | .minimum = 0, |
267 | .name = "Notch filter", | 251 | .maximum = 1, |
268 | .minimum = 0, | 252 | .step = 1, |
269 | .maximum = 1, | 253 | .default_value = 0x0, |
270 | .step = 1, | 254 | .off = 0, |
271 | .default_value = 0x0, | 255 | .reg = MO_HTOTAL, |
272 | .type = V4L2_CTRL_TYPE_INTEGER, | 256 | .mask = 3 << 11, |
273 | }, | 257 | .shift = 11, |
274 | .off = 0, | 258 | } |
275 | .reg = MO_HTOTAL, | 259 | }; |
276 | .mask = 3 << 11, | 260 | |
277 | .shift = 11, | 261 | static const struct cx88_ctrl cx8800_aud_ctls[] = { |
278 | }, { | 262 | { |
279 | /* --- audio --- */ | 263 | /* --- audio --- */ |
280 | .v = { | 264 | .id = V4L2_CID_AUDIO_MUTE, |
281 | .id = V4L2_CID_AUDIO_MUTE, | 265 | .minimum = 0, |
282 | .name = "Mute", | 266 | .maximum = 1, |
283 | .minimum = 0, | 267 | .default_value = 1, |
284 | .maximum = 1, | 268 | .reg = AUD_VOL_CTL, |
285 | .default_value = 1, | 269 | .sreg = SHADOW_AUD_VOL_CTL, |
286 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 270 | .mask = (1 << 6), |
287 | }, | 271 | .shift = 6, |
288 | .reg = AUD_VOL_CTL, | ||
289 | .sreg = SHADOW_AUD_VOL_CTL, | ||
290 | .mask = (1 << 6), | ||
291 | .shift = 6, | ||
292 | },{ | 272 | },{ |
293 | .v = { | 273 | .id = V4L2_CID_AUDIO_VOLUME, |
294 | .id = V4L2_CID_AUDIO_VOLUME, | 274 | .minimum = 0, |
295 | .name = "Volume", | 275 | .maximum = 0x3f, |
296 | .minimum = 0, | 276 | .step = 1, |
297 | .maximum = 0x3f, | 277 | .default_value = 0x3f, |
298 | .step = 1, | 278 | .reg = AUD_VOL_CTL, |
299 | .default_value = 0x3f, | 279 | .sreg = SHADOW_AUD_VOL_CTL, |
300 | .type = V4L2_CTRL_TYPE_INTEGER, | 280 | .mask = 0x3f, |
301 | }, | 281 | .shift = 0, |
302 | .reg = AUD_VOL_CTL, | ||
303 | .sreg = SHADOW_AUD_VOL_CTL, | ||
304 | .mask = 0x3f, | ||
305 | .shift = 0, | ||
306 | },{ | 282 | },{ |
307 | .v = { | 283 | .id = V4L2_CID_AUDIO_BALANCE, |
308 | .id = V4L2_CID_AUDIO_BALANCE, | 284 | .minimum = 0, |
309 | .name = "Balance", | 285 | .maximum = 0x7f, |
310 | .minimum = 0, | 286 | .step = 1, |
311 | .maximum = 0x7f, | 287 | .default_value = 0x40, |
312 | .step = 1, | 288 | .reg = AUD_BAL_CTL, |
313 | .default_value = 0x40, | 289 | .sreg = SHADOW_AUD_BAL_CTL, |
314 | .type = V4L2_CTRL_TYPE_INTEGER, | 290 | .mask = 0x7f, |
315 | }, | 291 | .shift = 0, |
316 | .reg = AUD_BAL_CTL, | ||
317 | .sreg = SHADOW_AUD_BAL_CTL, | ||
318 | .mask = 0x7f, | ||
319 | .shift = 0, | ||
320 | } | 292 | } |
321 | }; | 293 | }; |
322 | enum { CX8800_CTLS = ARRAY_SIZE(cx8800_ctls) }; | ||
323 | |||
324 | /* Must be sorted from low to high control ID! */ | ||
325 | const u32 cx88_user_ctrls[] = { | ||
326 | V4L2_CID_USER_CLASS, | ||
327 | V4L2_CID_BRIGHTNESS, | ||
328 | V4L2_CID_CONTRAST, | ||
329 | V4L2_CID_SATURATION, | ||
330 | V4L2_CID_HUE, | ||
331 | V4L2_CID_AUDIO_VOLUME, | ||
332 | V4L2_CID_AUDIO_BALANCE, | ||
333 | V4L2_CID_AUDIO_MUTE, | ||
334 | V4L2_CID_SHARPNESS, | ||
335 | V4L2_CID_CHROMA_AGC, | ||
336 | V4L2_CID_COLOR_KILLER, | ||
337 | V4L2_CID_BAND_STOP_FILTER, | ||
338 | 0 | ||
339 | }; | ||
340 | EXPORT_SYMBOL(cx88_user_ctrls); | ||
341 | 294 | ||
342 | static const u32 * const ctrl_classes[] = { | 295 | enum { |
343 | cx88_user_ctrls, | 296 | CX8800_VID_CTLS = ARRAY_SIZE(cx8800_vid_ctls), |
344 | NULL | 297 | CX8800_AUD_CTLS = ARRAY_SIZE(cx8800_aud_ctls), |
345 | }; | 298 | }; |
346 | 299 | ||
347 | int cx8800_ctrl_query(struct cx88_core *core, struct v4l2_queryctrl *qctrl) | ||
348 | { | ||
349 | int i; | ||
350 | |||
351 | if (qctrl->id < V4L2_CID_BASE || | ||
352 | qctrl->id >= V4L2_CID_LASTP1) | ||
353 | return -EINVAL; | ||
354 | for (i = 0; i < CX8800_CTLS; i++) | ||
355 | if (cx8800_ctls[i].v.id == qctrl->id) | ||
356 | break; | ||
357 | if (i == CX8800_CTLS) { | ||
358 | *qctrl = no_ctl; | ||
359 | return 0; | ||
360 | } | ||
361 | *qctrl = cx8800_ctls[i].v; | ||
362 | /* Report chroma AGC as inactive when SECAM is selected */ | ||
363 | if (cx8800_ctls[i].v.id == V4L2_CID_CHROMA_AGC && | ||
364 | core->tvnorm & V4L2_STD_SECAM) | ||
365 | qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; | ||
366 | |||
367 | return 0; | ||
368 | } | ||
369 | EXPORT_SYMBOL(cx8800_ctrl_query); | ||
370 | |||
371 | /* ------------------------------------------------------------------- */ | 300 | /* ------------------------------------------------------------------- */ |
372 | /* resource management */ | 301 | /* resource management */ |
373 | 302 | ||
@@ -591,8 +520,9 @@ static int | |||
591 | buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) | 520 | buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) |
592 | { | 521 | { |
593 | struct cx8800_fh *fh = q->priv_data; | 522 | struct cx8800_fh *fh = q->priv_data; |
523 | struct cx8800_dev *dev = fh->dev; | ||
594 | 524 | ||
595 | *size = fh->fmt->depth*fh->width*fh->height >> 3; | 525 | *size = dev->fmt->depth * dev->width * dev->height >> 3; |
596 | if (0 == *count) | 526 | if (0 == *count) |
597 | *count = 32; | 527 | *count = 32; |
598 | if (*size * *count > vid_limit * 1024 * 1024) | 528 | if (*size * *count > vid_limit * 1024 * 1024) |
@@ -611,21 +541,21 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | |||
611 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | 541 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); |
612 | int rc, init_buffer = 0; | 542 | int rc, init_buffer = 0; |
613 | 543 | ||
614 | BUG_ON(NULL == fh->fmt); | 544 | BUG_ON(NULL == dev->fmt); |
615 | if (fh->width < 48 || fh->width > norm_maxw(core->tvnorm) || | 545 | if (dev->width < 48 || dev->width > norm_maxw(core->tvnorm) || |
616 | fh->height < 32 || fh->height > norm_maxh(core->tvnorm)) | 546 | dev->height < 32 || dev->height > norm_maxh(core->tvnorm)) |
617 | return -EINVAL; | 547 | return -EINVAL; |
618 | buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3; | 548 | buf->vb.size = (dev->width * dev->height * dev->fmt->depth) >> 3; |
619 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | 549 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) |
620 | return -EINVAL; | 550 | return -EINVAL; |
621 | 551 | ||
622 | if (buf->fmt != fh->fmt || | 552 | if (buf->fmt != dev->fmt || |
623 | buf->vb.width != fh->width || | 553 | buf->vb.width != dev->width || |
624 | buf->vb.height != fh->height || | 554 | buf->vb.height != dev->height || |
625 | buf->vb.field != field) { | 555 | buf->vb.field != field) { |
626 | buf->fmt = fh->fmt; | 556 | buf->fmt = dev->fmt; |
627 | buf->vb.width = fh->width; | 557 | buf->vb.width = dev->width; |
628 | buf->vb.height = fh->height; | 558 | buf->vb.height = dev->height; |
629 | buf->vb.field = field; | 559 | buf->vb.field = field; |
630 | init_buffer = 1; | 560 | init_buffer = 1; |
631 | } | 561 | } |
@@ -675,7 +605,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | |||
675 | } | 605 | } |
676 | dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", | 606 | dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n", |
677 | buf, buf->vb.i, | 607 | buf, buf->vb.i, |
678 | fh->width, fh->height, fh->fmt->depth, fh->fmt->name, | 608 | dev->width, dev->height, dev->fmt->depth, dev->fmt->name, |
679 | (unsigned long)buf->risc.dma); | 609 | (unsigned long)buf->risc.dma); |
680 | 610 | ||
681 | buf->vb.state = VIDEOBUF_PREPARED; | 611 | buf->vb.state = VIDEOBUF_PREPARED; |
@@ -755,12 +685,15 @@ static const struct videobuf_queue_ops cx8800_video_qops = { | |||
755 | 685 | ||
756 | /* ------------------------------------------------------------------ */ | 686 | /* ------------------------------------------------------------------ */ |
757 | 687 | ||
758 | static struct videobuf_queue* get_queue(struct cx8800_fh *fh) | 688 | static struct videobuf_queue *get_queue(struct file *file) |
759 | { | 689 | { |
760 | switch (fh->type) { | 690 | struct video_device *vdev = video_devdata(file); |
761 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 691 | struct cx8800_fh *fh = file->private_data; |
692 | |||
693 | switch (vdev->vfl_type) { | ||
694 | case VFL_TYPE_GRABBER: | ||
762 | return &fh->vidq; | 695 | return &fh->vidq; |
763 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 696 | case VFL_TYPE_VBI: |
764 | return &fh->vbiq; | 697 | return &fh->vbiq; |
765 | default: | 698 | default: |
766 | BUG(); | 699 | BUG(); |
@@ -768,12 +701,14 @@ static struct videobuf_queue* get_queue(struct cx8800_fh *fh) | |||
768 | } | 701 | } |
769 | } | 702 | } |
770 | 703 | ||
771 | static int get_ressource(struct cx8800_fh *fh) | 704 | static int get_resource(struct file *file) |
772 | { | 705 | { |
773 | switch (fh->type) { | 706 | struct video_device *vdev = video_devdata(file); |
774 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 707 | |
708 | switch (vdev->vfl_type) { | ||
709 | case VFL_TYPE_GRABBER: | ||
775 | return RESOURCE_VIDEO; | 710 | return RESOURCE_VIDEO; |
776 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 711 | case VFL_TYPE_VBI: |
777 | return RESOURCE_VBI; | 712 | return RESOURCE_VBI; |
778 | default: | 713 | default: |
779 | BUG(); | 714 | BUG(); |
@@ -810,13 +745,9 @@ static int video_open(struct file *file) | |||
810 | if (unlikely(!fh)) | 745 | if (unlikely(!fh)) |
811 | return -ENOMEM; | 746 | return -ENOMEM; |
812 | 747 | ||
748 | v4l2_fh_init(&fh->fh, vdev); | ||
813 | file->private_data = fh; | 749 | file->private_data = fh; |
814 | fh->dev = dev; | 750 | fh->dev = dev; |
815 | fh->radio = radio; | ||
816 | fh->type = type; | ||
817 | fh->width = 320; | ||
818 | fh->height = 240; | ||
819 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); | ||
820 | 751 | ||
821 | mutex_lock(&core->lock); | 752 | mutex_lock(&core->lock); |
822 | 753 | ||
@@ -833,7 +764,7 @@ static int video_open(struct file *file) | |||
833 | sizeof(struct cx88_buffer), | 764 | sizeof(struct cx88_buffer), |
834 | fh, NULL); | 765 | fh, NULL); |
835 | 766 | ||
836 | if (fh->radio) { | 767 | if (vdev->vfl_type == VFL_TYPE_RADIO) { |
837 | dprintk(1,"video_open: setting radio device\n"); | 768 | dprintk(1,"video_open: setting radio device\n"); |
838 | cx_write(MO_GP3_IO, core->board.radio.gpio3); | 769 | cx_write(MO_GP3_IO, core->board.radio.gpio3); |
839 | cx_write(MO_GP0_IO, core->board.radio.gpio0); | 770 | cx_write(MO_GP0_IO, core->board.radio.gpio0); |
@@ -859,6 +790,7 @@ static int video_open(struct file *file) | |||
859 | 790 | ||
860 | core->users++; | 791 | core->users++; |
861 | mutex_unlock(&core->lock); | 792 | mutex_unlock(&core->lock); |
793 | v4l2_fh_add(&fh->fh); | ||
862 | 794 | ||
863 | return 0; | 795 | return 0; |
864 | } | 796 | } |
@@ -866,15 +798,16 @@ static int video_open(struct file *file) | |||
866 | static ssize_t | 798 | static ssize_t |
867 | video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | 799 | video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) |
868 | { | 800 | { |
801 | struct video_device *vdev = video_devdata(file); | ||
869 | struct cx8800_fh *fh = file->private_data; | 802 | struct cx8800_fh *fh = file->private_data; |
870 | 803 | ||
871 | switch (fh->type) { | 804 | switch (vdev->vfl_type) { |
872 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 805 | case VFL_TYPE_GRABBER: |
873 | if (res_locked(fh->dev,RESOURCE_VIDEO)) | 806 | if (res_locked(fh->dev,RESOURCE_VIDEO)) |
874 | return -EBUSY; | 807 | return -EBUSY; |
875 | return videobuf_read_one(&fh->vidq, data, count, ppos, | 808 | return videobuf_read_one(&fh->vidq, data, count, ppos, |
876 | file->f_flags & O_NONBLOCK); | 809 | file->f_flags & O_NONBLOCK); |
877 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 810 | case VFL_TYPE_VBI: |
878 | if (!res_get(fh->dev,fh,RESOURCE_VBI)) | 811 | if (!res_get(fh->dev,fh,RESOURCE_VBI)) |
879 | return -EBUSY; | 812 | return -EBUSY; |
880 | return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1, | 813 | return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1, |
@@ -888,16 +821,16 @@ video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | |||
888 | static unsigned int | 821 | static unsigned int |
889 | video_poll(struct file *file, struct poll_table_struct *wait) | 822 | video_poll(struct file *file, struct poll_table_struct *wait) |
890 | { | 823 | { |
824 | struct video_device *vdev = video_devdata(file); | ||
891 | struct cx8800_fh *fh = file->private_data; | 825 | struct cx8800_fh *fh = file->private_data; |
892 | struct cx88_buffer *buf; | 826 | struct cx88_buffer *buf; |
893 | unsigned int rc = POLLERR; | 827 | unsigned int rc = v4l2_ctrl_poll(file, wait); |
894 | 828 | ||
895 | if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { | 829 | if (vdev->vfl_type == VFL_TYPE_VBI) { |
896 | if (!res_get(fh->dev,fh,RESOURCE_VBI)) | 830 | if (!res_get(fh->dev,fh,RESOURCE_VBI)) |
897 | return POLLERR; | 831 | return rc | POLLERR; |
898 | return videobuf_poll_stream(file, &fh->vbiq, wait); | 832 | return rc | videobuf_poll_stream(file, &fh->vbiq, wait); |
899 | } | 833 | } |
900 | |||
901 | mutex_lock(&fh->vidq.vb_lock); | 834 | mutex_lock(&fh->vidq.vb_lock); |
902 | if (res_check(fh,RESOURCE_VIDEO)) { | 835 | if (res_check(fh,RESOURCE_VIDEO)) { |
903 | /* streaming capture */ | 836 | /* streaming capture */ |
@@ -913,9 +846,7 @@ video_poll(struct file *file, struct poll_table_struct *wait) | |||
913 | poll_wait(file, &buf->vb.done, wait); | 846 | poll_wait(file, &buf->vb.done, wait); |
914 | if (buf->vb.state == VIDEOBUF_DONE || | 847 | if (buf->vb.state == VIDEOBUF_DONE || |
915 | buf->vb.state == VIDEOBUF_ERROR) | 848 | buf->vb.state == VIDEOBUF_ERROR) |
916 | rc = POLLIN|POLLRDNORM; | 849 | rc |= POLLIN|POLLRDNORM; |
917 | else | ||
918 | rc = 0; | ||
919 | done: | 850 | done: |
920 | mutex_unlock(&fh->vidq.vb_lock); | 851 | mutex_unlock(&fh->vidq.vb_lock); |
921 | return rc; | 852 | return rc; |
@@ -952,6 +883,8 @@ static int video_release(struct file *file) | |||
952 | videobuf_mmap_free(&fh->vbiq); | 883 | videobuf_mmap_free(&fh->vbiq); |
953 | 884 | ||
954 | mutex_lock(&dev->core->lock); | 885 | mutex_lock(&dev->core->lock); |
886 | v4l2_fh_del(&fh->fh); | ||
887 | v4l2_fh_exit(&fh->fh); | ||
955 | file->private_data = NULL; | 888 | file->private_data = NULL; |
956 | kfree(fh); | 889 | kfree(fh); |
957 | 890 | ||
@@ -966,156 +899,104 @@ static int video_release(struct file *file) | |||
966 | static int | 899 | static int |
967 | video_mmap(struct file *file, struct vm_area_struct * vma) | 900 | video_mmap(struct file *file, struct vm_area_struct * vma) |
968 | { | 901 | { |
969 | struct cx8800_fh *fh = file->private_data; | 902 | return videobuf_mmap_mapper(get_queue(file), vma); |
970 | |||
971 | return videobuf_mmap_mapper(get_queue(fh), vma); | ||
972 | } | 903 | } |
973 | 904 | ||
974 | /* ------------------------------------------------------------------ */ | 905 | /* ------------------------------------------------------------------ */ |
975 | /* VIDEO CTRL IOCTLS */ | 906 | /* VIDEO CTRL IOCTLS */ |
976 | 907 | ||
977 | int cx88_get_control (struct cx88_core *core, struct v4l2_control *ctl) | 908 | static int cx8800_s_vid_ctrl(struct v4l2_ctrl *ctrl) |
978 | { | 909 | { |
979 | const struct cx88_ctrl *c = NULL; | 910 | struct cx88_core *core = |
980 | u32 value; | 911 | container_of(ctrl->handler, struct cx88_core, video_hdl); |
981 | int i; | 912 | const struct cx88_ctrl *cc = ctrl->priv; |
913 | u32 value, mask; | ||
982 | 914 | ||
983 | for (i = 0; i < CX8800_CTLS; i++) | 915 | mask = cc->mask; |
984 | if (cx8800_ctls[i].v.id == ctl->id) | 916 | switch (ctrl->id) { |
985 | c = &cx8800_ctls[i]; | 917 | case V4L2_CID_SATURATION: |
986 | if (unlikely(NULL == c)) | 918 | /* special v_sat handling */ |
987 | return -EINVAL; | ||
988 | 919 | ||
989 | value = c->sreg ? cx_sread(c->sreg) : cx_read(c->reg); | 920 | value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; |
990 | switch (ctl->id) { | 921 | |
991 | case V4L2_CID_AUDIO_BALANCE: | 922 | if (core->tvnorm & V4L2_STD_SECAM) { |
992 | ctl->value = ((value & 0x7f) < 0x40) ? ((value & 0x7f) + 0x40) | 923 | /* For SECAM, both U and V sat should be equal */ |
993 | : (0x7f - (value & 0x7f)); | 924 | value = value << 8 | value; |
994 | break; | 925 | } else { |
995 | case V4L2_CID_AUDIO_VOLUME: | 926 | /* Keeps U Saturation proportional to V Sat */ |
996 | ctl->value = 0x3f - (value & 0x3f); | 927 | value = (value * 0x5a) / 0x7f << 8 | value; |
928 | } | ||
929 | mask = 0xffff; | ||
997 | break; | 930 | break; |
998 | case V4L2_CID_SHARPNESS: | 931 | case V4L2_CID_SHARPNESS: |
999 | ctl->value = ((value & 0x0200) ? (((value & 0x0180) >> 7) + 1) | 932 | /* 0b000, 0b100, 0b101, 0b110, or 0b111 */ |
1000 | : 0); | 933 | value = (ctrl->val < 1 ? 0 : ((ctrl->val + 3) << 7)); |
934 | /* needs to be set for both fields */ | ||
935 | cx_andor(MO_FILTER_EVEN, mask, value); | ||
936 | break; | ||
937 | case V4L2_CID_CHROMA_AGC: | ||
938 | value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; | ||
1001 | break; | 939 | break; |
1002 | default: | 940 | default: |
1003 | ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift; | 941 | value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; |
1004 | break; | 942 | break; |
1005 | } | 943 | } |
1006 | dprintk(1,"get_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", | 944 | dprintk(1, "set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", |
1007 | ctl->id, c->v.name, ctl->value, c->reg, | 945 | ctrl->id, ctrl->name, ctrl->val, cc->reg, value, |
1008 | value,c->mask, c->sreg ? " [shadowed]" : ""); | 946 | mask, cc->sreg ? " [shadowed]" : ""); |
947 | if (cc->sreg) | ||
948 | cx_sandor(cc->sreg, cc->reg, mask, value); | ||
949 | else | ||
950 | cx_andor(cc->reg, mask, value); | ||
1009 | return 0; | 951 | return 0; |
1010 | } | 952 | } |
1011 | EXPORT_SYMBOL(cx88_get_control); | ||
1012 | 953 | ||
1013 | int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl) | 954 | static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl) |
1014 | { | 955 | { |
1015 | const struct cx88_ctrl *c = NULL; | 956 | struct cx88_core *core = |
957 | container_of(ctrl->handler, struct cx88_core, audio_hdl); | ||
958 | const struct cx88_ctrl *cc = ctrl->priv; | ||
1016 | u32 value,mask; | 959 | u32 value,mask; |
1017 | int i; | ||
1018 | |||
1019 | for (i = 0; i < CX8800_CTLS; i++) { | ||
1020 | if (cx8800_ctls[i].v.id == ctl->id) { | ||
1021 | c = &cx8800_ctls[i]; | ||
1022 | } | ||
1023 | } | ||
1024 | if (unlikely(NULL == c)) | ||
1025 | return -EINVAL; | ||
1026 | |||
1027 | if (ctl->value < c->v.minimum) | ||
1028 | ctl->value = c->v.minimum; | ||
1029 | if (ctl->value > c->v.maximum) | ||
1030 | ctl->value = c->v.maximum; | ||
1031 | 960 | ||
1032 | /* Pass changes onto any WM8775 */ | 961 | /* Pass changes onto any WM8775 */ |
1033 | if (core->board.audio_chip == V4L2_IDENT_WM8775) { | 962 | if (core->board.audio_chip == V4L2_IDENT_WM8775) { |
1034 | struct v4l2_control client_ctl; | 963 | switch (ctrl->id) { |
1035 | memset(&client_ctl, 0, sizeof(client_ctl)); | ||
1036 | client_ctl.id = ctl->id; | ||
1037 | |||
1038 | switch (ctl->id) { | ||
1039 | case V4L2_CID_AUDIO_MUTE: | 964 | case V4L2_CID_AUDIO_MUTE: |
1040 | client_ctl.value = ctl->value; | 965 | wm8775_s_ctrl(core, ctrl->id, ctrl->val); |
1041 | break; | 966 | break; |
1042 | case V4L2_CID_AUDIO_VOLUME: | 967 | case V4L2_CID_AUDIO_VOLUME: |
1043 | client_ctl.value = (ctl->value) ? | 968 | wm8775_s_ctrl(core, ctrl->id, (ctrl->val) ? |
1044 | (0x90 + ctl->value) << 8 : 0; | 969 | (0x90 + ctrl->val) << 8 : 0); |
1045 | break; | 970 | break; |
1046 | case V4L2_CID_AUDIO_BALANCE: | 971 | case V4L2_CID_AUDIO_BALANCE: |
1047 | client_ctl.value = ctl->value << 9; | 972 | wm8775_s_ctrl(core, ctrl->id, ctrl->val << 9); |
1048 | break; | 973 | break; |
1049 | default: | 974 | default: |
1050 | client_ctl.id = 0; | ||
1051 | break; | 975 | break; |
1052 | } | 976 | } |
1053 | if (client_ctl.id) | ||
1054 | call_hw(core, WM8775_GID, core, s_ctrl, &client_ctl); | ||
1055 | } | 977 | } |
1056 | 978 | ||
1057 | mask=c->mask; | 979 | mask = cc->mask; |
1058 | switch (ctl->id) { | 980 | switch (ctrl->id) { |
1059 | case V4L2_CID_AUDIO_BALANCE: | 981 | case V4L2_CID_AUDIO_BALANCE: |
1060 | value = (ctl->value < 0x40) ? (0x7f - ctl->value) : (ctl->value - 0x40); | 982 | value = (ctrl->val < 0x40) ? (0x7f - ctrl->val) : (ctrl->val - 0x40); |
1061 | break; | 983 | break; |
1062 | case V4L2_CID_AUDIO_VOLUME: | 984 | case V4L2_CID_AUDIO_VOLUME: |
1063 | value = 0x3f - (ctl->value & 0x3f); | 985 | value = 0x3f - (ctrl->val & 0x3f); |
1064 | break; | ||
1065 | case V4L2_CID_SATURATION: | ||
1066 | /* special v_sat handling */ | ||
1067 | |||
1068 | value = ((ctl->value - c->off) << c->shift) & c->mask; | ||
1069 | |||
1070 | if (core->tvnorm & V4L2_STD_SECAM) { | ||
1071 | /* For SECAM, both U and V sat should be equal */ | ||
1072 | value=value<<8|value; | ||
1073 | } else { | ||
1074 | /* Keeps U Saturation proportional to V Sat */ | ||
1075 | value=(value*0x5a)/0x7f<<8|value; | ||
1076 | } | ||
1077 | mask=0xffff; | ||
1078 | break; | ||
1079 | case V4L2_CID_SHARPNESS: | ||
1080 | /* 0b000, 0b100, 0b101, 0b110, or 0b111 */ | ||
1081 | value = (ctl->value < 1 ? 0 : ((ctl->value + 3) << 7)); | ||
1082 | /* needs to be set for both fields */ | ||
1083 | cx_andor(MO_FILTER_EVEN, mask, value); | ||
1084 | break; | ||
1085 | case V4L2_CID_CHROMA_AGC: | ||
1086 | /* Do not allow chroma AGC to be enabled for SECAM */ | ||
1087 | value = ((ctl->value - c->off) << c->shift) & c->mask; | ||
1088 | if (core->tvnorm & V4L2_STD_SECAM && value) | ||
1089 | return -EINVAL; | ||
1090 | break; | 986 | break; |
1091 | default: | 987 | default: |
1092 | value = ((ctl->value - c->off) << c->shift) & c->mask; | 988 | value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; |
1093 | break; | 989 | break; |
1094 | } | 990 | } |
1095 | dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", | 991 | dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", |
1096 | ctl->id, c->v.name, ctl->value, c->reg, value, | 992 | ctrl->id, ctrl->name, ctrl->val, cc->reg, value, |
1097 | mask, c->sreg ? " [shadowed]" : ""); | 993 | mask, cc->sreg ? " [shadowed]" : ""); |
1098 | if (c->sreg) { | 994 | if (cc->sreg) |
1099 | cx_sandor(c->sreg, c->reg, mask, value); | 995 | cx_sandor(cc->sreg, cc->reg, mask, value); |
1100 | } else { | 996 | else |
1101 | cx_andor(c->reg, mask, value); | 997 | cx_andor(cc->reg, mask, value); |
1102 | } | ||
1103 | return 0; | 998 | return 0; |
1104 | } | 999 | } |
1105 | EXPORT_SYMBOL(cx88_set_control); | ||
1106 | |||
1107 | static void init_controls(struct cx88_core *core) | ||
1108 | { | ||
1109 | struct v4l2_control ctrl; | ||
1110 | int i; | ||
1111 | |||
1112 | for (i = 0; i < CX8800_CTLS; i++) { | ||
1113 | ctrl.id=cx8800_ctls[i].v.id; | ||
1114 | ctrl.value=cx8800_ctls[i].v.default_value; | ||
1115 | |||
1116 | cx88_set_control(core, &ctrl); | ||
1117 | } | ||
1118 | } | ||
1119 | 1000 | ||
1120 | /* ------------------------------------------------------------------ */ | 1001 | /* ------------------------------------------------------------------ */ |
1121 | /* VIDEO IOCTLS */ | 1002 | /* VIDEO IOCTLS */ |
@@ -1124,15 +1005,17 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
1124 | struct v4l2_format *f) | 1005 | struct v4l2_format *f) |
1125 | { | 1006 | { |
1126 | struct cx8800_fh *fh = priv; | 1007 | struct cx8800_fh *fh = priv; |
1008 | struct cx8800_dev *dev = fh->dev; | ||
1127 | 1009 | ||
1128 | f->fmt.pix.width = fh->width; | 1010 | f->fmt.pix.width = dev->width; |
1129 | f->fmt.pix.height = fh->height; | 1011 | f->fmt.pix.height = dev->height; |
1130 | f->fmt.pix.field = fh->vidq.field; | 1012 | f->fmt.pix.field = fh->vidq.field; |
1131 | f->fmt.pix.pixelformat = fh->fmt->fourcc; | 1013 | f->fmt.pix.pixelformat = dev->fmt->fourcc; |
1132 | f->fmt.pix.bytesperline = | 1014 | f->fmt.pix.bytesperline = |
1133 | (f->fmt.pix.width * fh->fmt->depth) >> 3; | 1015 | (f->fmt.pix.width * dev->fmt->depth) >> 3; |
1134 | f->fmt.pix.sizeimage = | 1016 | f->fmt.pix.sizeimage = |
1135 | f->fmt.pix.height * f->fmt.pix.bytesperline; | 1017 | f->fmt.pix.height * f->fmt.pix.bytesperline; |
1018 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
1136 | return 0; | 1019 | return 0; |
1137 | } | 1020 | } |
1138 | 1021 | ||
@@ -1184,33 +1067,54 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1184 | struct v4l2_format *f) | 1067 | struct v4l2_format *f) |
1185 | { | 1068 | { |
1186 | struct cx8800_fh *fh = priv; | 1069 | struct cx8800_fh *fh = priv; |
1070 | struct cx8800_dev *dev = fh->dev; | ||
1187 | int err = vidioc_try_fmt_vid_cap (file,priv,f); | 1071 | int err = vidioc_try_fmt_vid_cap (file,priv,f); |
1188 | 1072 | ||
1189 | if (0 != err) | 1073 | if (0 != err) |
1190 | return err; | 1074 | return err; |
1191 | fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 1075 | dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
1192 | fh->width = f->fmt.pix.width; | 1076 | dev->width = f->fmt.pix.width; |
1193 | fh->height = f->fmt.pix.height; | 1077 | dev->height = f->fmt.pix.height; |
1194 | fh->vidq.field = f->fmt.pix.field; | 1078 | fh->vidq.field = f->fmt.pix.field; |
1195 | return 0; | 1079 | return 0; |
1196 | } | 1080 | } |
1197 | 1081 | ||
1198 | static int vidioc_querycap (struct file *file, void *priv, | 1082 | void cx88_querycap(struct file *file, struct cx88_core *core, |
1083 | struct v4l2_capability *cap) | ||
1084 | { | ||
1085 | struct video_device *vdev = video_devdata(file); | ||
1086 | |||
1087 | strlcpy(cap->card, core->board.name, sizeof(cap->card)); | ||
1088 | cap->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; | ||
1089 | if (UNSET != core->board.tuner_type) | ||
1090 | cap->device_caps |= V4L2_CAP_TUNER; | ||
1091 | switch (vdev->vfl_type) { | ||
1092 | case VFL_TYPE_RADIO: | ||
1093 | cap->device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; | ||
1094 | break; | ||
1095 | case VFL_TYPE_GRABBER: | ||
1096 | cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE; | ||
1097 | break; | ||
1098 | case VFL_TYPE_VBI: | ||
1099 | cap->device_caps |= V4L2_CAP_VBI_CAPTURE; | ||
1100 | break; | ||
1101 | } | ||
1102 | cap->capabilities = cap->device_caps | V4L2_CAP_VIDEO_CAPTURE | | ||
1103 | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_DEVICE_CAPS; | ||
1104 | if (core->board.radio.type == CX88_RADIO) | ||
1105 | cap->capabilities |= V4L2_CAP_RADIO; | ||
1106 | } | ||
1107 | EXPORT_SYMBOL(cx88_querycap); | ||
1108 | |||
1109 | static int vidioc_querycap(struct file *file, void *priv, | ||
1199 | struct v4l2_capability *cap) | 1110 | struct v4l2_capability *cap) |
1200 | { | 1111 | { |
1201 | struct cx8800_dev *dev = ((struct cx8800_fh *)priv)->dev; | 1112 | struct cx8800_dev *dev = ((struct cx8800_fh *)priv)->dev; |
1202 | struct cx88_core *core = dev->core; | 1113 | struct cx88_core *core = dev->core; |
1203 | 1114 | ||
1204 | strcpy(cap->driver, "cx8800"); | 1115 | strcpy(cap->driver, "cx8800"); |
1205 | strlcpy(cap->card, core->board.name, sizeof(cap->card)); | 1116 | sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); |
1206 | sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci)); | 1117 | cx88_querycap(file, core, cap); |
1207 | cap->capabilities = | ||
1208 | V4L2_CAP_VIDEO_CAPTURE | | ||
1209 | V4L2_CAP_READWRITE | | ||
1210 | V4L2_CAP_STREAMING | | ||
1211 | V4L2_CAP_VBI_CAPTURE; | ||
1212 | if (UNSET != core->board.tuner_type) | ||
1213 | cap->capabilities |= V4L2_CAP_TUNER; | ||
1214 | return 0; | 1118 | return 0; |
1215 | } | 1119 | } |
1216 | 1120 | ||
@@ -1228,69 +1132,67 @@ static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, | |||
1228 | 1132 | ||
1229 | static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) | 1133 | static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) |
1230 | { | 1134 | { |
1231 | struct cx8800_fh *fh = priv; | 1135 | return videobuf_reqbufs(get_queue(file), p); |
1232 | return (videobuf_reqbufs(get_queue(fh), p)); | ||
1233 | } | 1136 | } |
1234 | 1137 | ||
1235 | static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p) | 1138 | static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p) |
1236 | { | 1139 | { |
1237 | struct cx8800_fh *fh = priv; | 1140 | return videobuf_querybuf(get_queue(file), p); |
1238 | return (videobuf_querybuf(get_queue(fh), p)); | ||
1239 | } | 1141 | } |
1240 | 1142 | ||
1241 | static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p) | 1143 | static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p) |
1242 | { | 1144 | { |
1243 | struct cx8800_fh *fh = priv; | 1145 | return videobuf_qbuf(get_queue(file), p); |
1244 | return (videobuf_qbuf(get_queue(fh), p)); | ||
1245 | } | 1146 | } |
1246 | 1147 | ||
1247 | static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p) | 1148 | static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p) |
1248 | { | 1149 | { |
1249 | struct cx8800_fh *fh = priv; | 1150 | return videobuf_dqbuf(get_queue(file), p, |
1250 | return (videobuf_dqbuf(get_queue(fh), p, | 1151 | file->f_flags & O_NONBLOCK); |
1251 | file->f_flags & O_NONBLOCK)); | ||
1252 | } | 1152 | } |
1253 | 1153 | ||
1254 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | 1154 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) |
1255 | { | 1155 | { |
1156 | struct video_device *vdev = video_devdata(file); | ||
1256 | struct cx8800_fh *fh = priv; | 1157 | struct cx8800_fh *fh = priv; |
1257 | struct cx8800_dev *dev = fh->dev; | 1158 | struct cx8800_dev *dev = fh->dev; |
1258 | 1159 | ||
1259 | /* We should remember that this driver also supports teletext, */ | 1160 | if ((vdev->vfl_type == VFL_TYPE_GRABBER && i != V4L2_BUF_TYPE_VIDEO_CAPTURE) || |
1260 | /* so we have to test if the v4l2_buf_type is VBI capture data. */ | 1161 | (vdev->vfl_type == VFL_TYPE_VBI && i != V4L2_BUF_TYPE_VBI_CAPTURE)) |
1261 | if (unlikely((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && | ||
1262 | (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE))) | ||
1263 | return -EINVAL; | ||
1264 | |||
1265 | if (unlikely(i != fh->type)) | ||
1266 | return -EINVAL; | 1162 | return -EINVAL; |
1267 | 1163 | ||
1268 | if (unlikely(!res_get(dev,fh,get_ressource(fh)))) | 1164 | if (unlikely(!res_get(dev, fh, get_resource(file)))) |
1269 | return -EBUSY; | 1165 | return -EBUSY; |
1270 | return videobuf_streamon(get_queue(fh)); | 1166 | return videobuf_streamon(get_queue(file)); |
1271 | } | 1167 | } |
1272 | 1168 | ||
1273 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | 1169 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) |
1274 | { | 1170 | { |
1171 | struct video_device *vdev = video_devdata(file); | ||
1275 | struct cx8800_fh *fh = priv; | 1172 | struct cx8800_fh *fh = priv; |
1276 | struct cx8800_dev *dev = fh->dev; | 1173 | struct cx8800_dev *dev = fh->dev; |
1277 | int err, res; | 1174 | int err, res; |
1278 | 1175 | ||
1279 | if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && | 1176 | if ((vdev->vfl_type == VFL_TYPE_GRABBER && i != V4L2_BUF_TYPE_VIDEO_CAPTURE) || |
1280 | (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)) | 1177 | (vdev->vfl_type == VFL_TYPE_VBI && i != V4L2_BUF_TYPE_VBI_CAPTURE)) |
1281 | return -EINVAL; | 1178 | return -EINVAL; |
1282 | 1179 | ||
1283 | if (i != fh->type) | 1180 | res = get_resource(file); |
1284 | return -EINVAL; | 1181 | err = videobuf_streamoff(get_queue(file)); |
1285 | |||
1286 | res = get_ressource(fh); | ||
1287 | err = videobuf_streamoff(get_queue(fh)); | ||
1288 | if (err < 0) | 1182 | if (err < 0) |
1289 | return err; | 1183 | return err; |
1290 | res_free(dev,fh,res); | 1184 | res_free(dev,fh,res); |
1291 | return 0; | 1185 | return 0; |
1292 | } | 1186 | } |
1293 | 1187 | ||
1188 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorm) | ||
1189 | { | ||
1190 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | ||
1191 | |||
1192 | *tvnorm = core->tvnorm; | ||
1193 | return 0; | ||
1194 | } | ||
1195 | |||
1294 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *tvnorms) | 1196 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *tvnorms) |
1295 | { | 1197 | { |
1296 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | 1198 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; |
@@ -1327,8 +1229,8 @@ int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i) | |||
1327 | if ((CX88_VMUX_TELEVISION == INPUT(n).type) || | 1229 | if ((CX88_VMUX_TELEVISION == INPUT(n).type) || |
1328 | (CX88_VMUX_CABLE == INPUT(n).type)) { | 1230 | (CX88_VMUX_CABLE == INPUT(n).type)) { |
1329 | i->type = V4L2_INPUT_TYPE_TUNER; | 1231 | i->type = V4L2_INPUT_TYPE_TUNER; |
1330 | i->std = CX88_NORMS; | ||
1331 | } | 1232 | } |
1233 | i->std = CX88_NORMS; | ||
1332 | return 0; | 1234 | return 0; |
1333 | } | 1235 | } |
1334 | EXPORT_SYMBOL(cx88_enum_input); | 1236 | EXPORT_SYMBOL(cx88_enum_input); |
@@ -1354,6 +1256,8 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int i) | |||
1354 | 1256 | ||
1355 | if (i >= 4) | 1257 | if (i >= 4) |
1356 | return -EINVAL; | 1258 | return -EINVAL; |
1259 | if (0 == INPUT(i).type) | ||
1260 | return -EINVAL; | ||
1357 | 1261 | ||
1358 | mutex_lock(&core->lock); | 1262 | mutex_lock(&core->lock); |
1359 | cx88_newstation(core); | 1263 | cx88_newstation(core); |
@@ -1362,35 +1266,6 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int i) | |||
1362 | return 0; | 1266 | return 0; |
1363 | } | 1267 | } |
1364 | 1268 | ||
1365 | |||
1366 | |||
1367 | static int vidioc_queryctrl (struct file *file, void *priv, | ||
1368 | struct v4l2_queryctrl *qctrl) | ||
1369 | { | ||
1370 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | ||
1371 | |||
1372 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | ||
1373 | if (unlikely(qctrl->id == 0)) | ||
1374 | return -EINVAL; | ||
1375 | return cx8800_ctrl_query(core, qctrl); | ||
1376 | } | ||
1377 | |||
1378 | static int vidioc_g_ctrl (struct file *file, void *priv, | ||
1379 | struct v4l2_control *ctl) | ||
1380 | { | ||
1381 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | ||
1382 | return | ||
1383 | cx88_get_control(core,ctl); | ||
1384 | } | ||
1385 | |||
1386 | static int vidioc_s_ctrl (struct file *file, void *priv, | ||
1387 | struct v4l2_control *ctl) | ||
1388 | { | ||
1389 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | ||
1390 | return | ||
1391 | cx88_set_control(core,ctl); | ||
1392 | } | ||
1393 | |||
1394 | static int vidioc_g_tuner (struct file *file, void *priv, | 1269 | static int vidioc_g_tuner (struct file *file, void *priv, |
1395 | struct v4l2_tuner *t) | 1270 | struct v4l2_tuner *t) |
1396 | { | 1271 | { |
@@ -1403,9 +1278,9 @@ static int vidioc_g_tuner (struct file *file, void *priv, | |||
1403 | return -EINVAL; | 1278 | return -EINVAL; |
1404 | 1279 | ||
1405 | strcpy(t->name, "Television"); | 1280 | strcpy(t->name, "Television"); |
1406 | t->type = V4L2_TUNER_ANALOG_TV; | ||
1407 | t->capability = V4L2_TUNER_CAP_NORM; | 1281 | t->capability = V4L2_TUNER_CAP_NORM; |
1408 | t->rangehigh = 0xffffffffUL; | 1282 | t->rangehigh = 0xffffffffUL; |
1283 | call_all(core, tuner, g_tuner, t); | ||
1409 | 1284 | ||
1410 | cx88_get_stereo(core ,t); | 1285 | cx88_get_stereo(core ,t); |
1411 | reg = cx_read(MO_DEVICE_STATUS); | 1286 | reg = cx_read(MO_DEVICE_STATUS); |
@@ -1435,9 +1310,9 @@ static int vidioc_g_frequency (struct file *file, void *priv, | |||
1435 | 1310 | ||
1436 | if (unlikely(UNSET == core->board.tuner_type)) | 1311 | if (unlikely(UNSET == core->board.tuner_type)) |
1437 | return -EINVAL; | 1312 | return -EINVAL; |
1313 | if (f->tuner) | ||
1314 | return -EINVAL; | ||
1438 | 1315 | ||
1439 | /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ | ||
1440 | f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
1441 | f->frequency = core->freq; | 1316 | f->frequency = core->freq; |
1442 | 1317 | ||
1443 | call_all(core, tuner, g_frequency, f); | 1318 | call_all(core, tuner, g_frequency, f); |
@@ -1454,9 +1329,10 @@ int cx88_set_freq (struct cx88_core *core, | |||
1454 | return -EINVAL; | 1329 | return -EINVAL; |
1455 | 1330 | ||
1456 | mutex_lock(&core->lock); | 1331 | mutex_lock(&core->lock); |
1457 | core->freq = f->frequency; | ||
1458 | cx88_newstation(core); | 1332 | cx88_newstation(core); |
1459 | call_all(core, tuner, s_frequency, f); | 1333 | call_all(core, tuner, s_frequency, f); |
1334 | call_all(core, tuner, g_frequency, f); | ||
1335 | core->freq = f->frequency; | ||
1460 | 1336 | ||
1461 | /* When changing channels it is required to reset TVAUDIO */ | 1337 | /* When changing channels it is required to reset TVAUDIO */ |
1462 | msleep (10); | 1338 | msleep (10); |
@@ -1474,13 +1350,17 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
1474 | struct cx8800_fh *fh = priv; | 1350 | struct cx8800_fh *fh = priv; |
1475 | struct cx88_core *core = fh->dev->core; | 1351 | struct cx88_core *core = fh->dev->core; |
1476 | 1352 | ||
1477 | if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV)) | 1353 | return cx88_set_freq(core, f); |
1478 | return -EINVAL; | 1354 | } |
1479 | if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO)) | ||
1480 | return -EINVAL; | ||
1481 | 1355 | ||
1482 | return | 1356 | static int vidioc_g_chip_ident(struct file *file, void *priv, |
1483 | cx88_set_freq (core,f); | 1357 | struct v4l2_dbg_chip_ident *chip) |
1358 | { | ||
1359 | if (!v4l2_chip_match_host(&chip->match)) | ||
1360 | return -EINVAL; | ||
1361 | chip->revision = 0; | ||
1362 | chip->ident = V4L2_IDENT_UNKNOWN; | ||
1363 | return 0; | ||
1484 | } | 1364 | } |
1485 | 1365 | ||
1486 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1366 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
@@ -1513,19 +1393,6 @@ static int vidioc_s_register (struct file *file, void *fh, | |||
1513 | /* RADIO ESPECIFIC IOCTLS */ | 1393 | /* RADIO ESPECIFIC IOCTLS */ |
1514 | /* ----------------------------------------------------------- */ | 1394 | /* ----------------------------------------------------------- */ |
1515 | 1395 | ||
1516 | static int radio_querycap (struct file *file, void *priv, | ||
1517 | struct v4l2_capability *cap) | ||
1518 | { | ||
1519 | struct cx8800_dev *dev = ((struct cx8800_fh *)priv)->dev; | ||
1520 | struct cx88_core *core = dev->core; | ||
1521 | |||
1522 | strcpy(cap->driver, "cx8800"); | ||
1523 | strlcpy(cap->card, core->board.name, sizeof(cap->card)); | ||
1524 | sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci)); | ||
1525 | cap->capabilities = V4L2_CAP_TUNER; | ||
1526 | return 0; | ||
1527 | } | ||
1528 | |||
1529 | static int radio_g_tuner (struct file *file, void *priv, | 1396 | static int radio_g_tuner (struct file *file, void *priv, |
1530 | struct v4l2_tuner *t) | 1397 | struct v4l2_tuner *t) |
1531 | { | 1398 | { |
@@ -1535,32 +1402,11 @@ static int radio_g_tuner (struct file *file, void *priv, | |||
1535 | return -EINVAL; | 1402 | return -EINVAL; |
1536 | 1403 | ||
1537 | strcpy(t->name, "Radio"); | 1404 | strcpy(t->name, "Radio"); |
1538 | t->type = V4L2_TUNER_RADIO; | ||
1539 | 1405 | ||
1540 | call_all(core, tuner, g_tuner, t); | 1406 | call_all(core, tuner, g_tuner, t); |
1541 | return 0; | 1407 | return 0; |
1542 | } | 1408 | } |
1543 | 1409 | ||
1544 | static int radio_enum_input (struct file *file, void *priv, | ||
1545 | struct v4l2_input *i) | ||
1546 | { | ||
1547 | if (i->index != 0) | ||
1548 | return -EINVAL; | ||
1549 | strcpy(i->name,"Radio"); | ||
1550 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
1551 | |||
1552 | return 0; | ||
1553 | } | ||
1554 | |||
1555 | static int radio_g_audio (struct file *file, void *priv, struct v4l2_audio *a) | ||
1556 | { | ||
1557 | if (unlikely(a->index)) | ||
1558 | return -EINVAL; | ||
1559 | |||
1560 | strcpy(a->name,"Radio"); | ||
1561 | return 0; | ||
1562 | } | ||
1563 | |||
1564 | /* FIXME: Should add a standard for radio */ | 1410 | /* FIXME: Should add a standard for radio */ |
1565 | 1411 | ||
1566 | static int radio_s_tuner (struct file *file, void *priv, | 1412 | static int radio_s_tuner (struct file *file, void *priv, |
@@ -1570,46 +1416,14 @@ static int radio_s_tuner (struct file *file, void *priv, | |||
1570 | 1416 | ||
1571 | if (0 != t->index) | 1417 | if (0 != t->index) |
1572 | return -EINVAL; | 1418 | return -EINVAL; |
1419 | if (t->audmode > V4L2_TUNER_MODE_STEREO) | ||
1420 | t->audmode = V4L2_TUNER_MODE_STEREO; | ||
1573 | 1421 | ||
1574 | call_all(core, tuner, s_tuner, t); | 1422 | call_all(core, tuner, s_tuner, t); |
1575 | 1423 | ||
1576 | return 0; | 1424 | return 0; |
1577 | } | 1425 | } |
1578 | 1426 | ||
1579 | static int radio_s_audio (struct file *file, void *fh, | ||
1580 | struct v4l2_audio *a) | ||
1581 | { | ||
1582 | return 0; | ||
1583 | } | ||
1584 | |||
1585 | static int radio_s_input (struct file *file, void *fh, unsigned int i) | ||
1586 | { | ||
1587 | return 0; | ||
1588 | } | ||
1589 | |||
1590 | static int radio_queryctrl (struct file *file, void *priv, | ||
1591 | struct v4l2_queryctrl *c) | ||
1592 | { | ||
1593 | int i; | ||
1594 | |||
1595 | if (c->id < V4L2_CID_BASE || | ||
1596 | c->id >= V4L2_CID_LASTP1) | ||
1597 | return -EINVAL; | ||
1598 | if (c->id == V4L2_CID_AUDIO_MUTE || | ||
1599 | c->id == V4L2_CID_AUDIO_VOLUME || | ||
1600 | c->id == V4L2_CID_AUDIO_BALANCE) { | ||
1601 | for (i = 0; i < CX8800_CTLS; i++) { | ||
1602 | if (cx8800_ctls[i].v.id == c->id) | ||
1603 | break; | ||
1604 | } | ||
1605 | if (i == CX8800_CTLS) | ||
1606 | return -EINVAL; | ||
1607 | *c = cx8800_ctls[i].v; | ||
1608 | } else | ||
1609 | *c = no_ctl; | ||
1610 | return 0; | ||
1611 | } | ||
1612 | |||
1613 | /* ----------------------------------------------------------- */ | 1427 | /* ----------------------------------------------------------- */ |
1614 | 1428 | ||
1615 | static void cx8800_vid_timeout(unsigned long data) | 1429 | static void cx8800_vid_timeout(unsigned long data) |
@@ -1752,63 +1566,89 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
1752 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | 1566 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, |
1753 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | 1567 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
1754 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | 1568 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, |
1755 | .vidioc_g_fmt_vbi_cap = cx8800_vbi_fmt, | ||
1756 | .vidioc_try_fmt_vbi_cap = cx8800_vbi_fmt, | ||
1757 | .vidioc_s_fmt_vbi_cap = cx8800_vbi_fmt, | ||
1758 | .vidioc_reqbufs = vidioc_reqbufs, | 1569 | .vidioc_reqbufs = vidioc_reqbufs, |
1759 | .vidioc_querybuf = vidioc_querybuf, | 1570 | .vidioc_querybuf = vidioc_querybuf, |
1760 | .vidioc_qbuf = vidioc_qbuf, | 1571 | .vidioc_qbuf = vidioc_qbuf, |
1761 | .vidioc_dqbuf = vidioc_dqbuf, | 1572 | .vidioc_dqbuf = vidioc_dqbuf, |
1573 | .vidioc_g_std = vidioc_g_std, | ||
1762 | .vidioc_s_std = vidioc_s_std, | 1574 | .vidioc_s_std = vidioc_s_std, |
1763 | .vidioc_enum_input = vidioc_enum_input, | 1575 | .vidioc_enum_input = vidioc_enum_input, |
1764 | .vidioc_g_input = vidioc_g_input, | 1576 | .vidioc_g_input = vidioc_g_input, |
1765 | .vidioc_s_input = vidioc_s_input, | 1577 | .vidioc_s_input = vidioc_s_input, |
1766 | .vidioc_queryctrl = vidioc_queryctrl, | ||
1767 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
1768 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
1769 | .vidioc_streamon = vidioc_streamon, | 1578 | .vidioc_streamon = vidioc_streamon, |
1770 | .vidioc_streamoff = vidioc_streamoff, | 1579 | .vidioc_streamoff = vidioc_streamoff, |
1771 | .vidioc_g_tuner = vidioc_g_tuner, | 1580 | .vidioc_g_tuner = vidioc_g_tuner, |
1772 | .vidioc_s_tuner = vidioc_s_tuner, | 1581 | .vidioc_s_tuner = vidioc_s_tuner, |
1773 | .vidioc_g_frequency = vidioc_g_frequency, | 1582 | .vidioc_g_frequency = vidioc_g_frequency, |
1774 | .vidioc_s_frequency = vidioc_s_frequency, | 1583 | .vidioc_s_frequency = vidioc_s_frequency, |
1584 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
1585 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
1586 | .vidioc_g_chip_ident = vidioc_g_chip_ident, | ||
1775 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1587 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1776 | .vidioc_g_register = vidioc_g_register, | 1588 | .vidioc_g_register = vidioc_g_register, |
1777 | .vidioc_s_register = vidioc_s_register, | 1589 | .vidioc_s_register = vidioc_s_register, |
1778 | #endif | 1590 | #endif |
1779 | }; | 1591 | }; |
1780 | 1592 | ||
1781 | static struct video_device cx8800_vbi_template; | ||
1782 | |||
1783 | static const struct video_device cx8800_video_template = { | 1593 | static const struct video_device cx8800_video_template = { |
1784 | .name = "cx8800-video", | 1594 | .name = "cx8800-video", |
1785 | .fops = &video_fops, | 1595 | .fops = &video_fops, |
1786 | .ioctl_ops = &video_ioctl_ops, | 1596 | .ioctl_ops = &video_ioctl_ops, |
1787 | .tvnorms = CX88_NORMS, | 1597 | .tvnorms = CX88_NORMS, |
1788 | .current_norm = V4L2_STD_NTSC_M, | 1598 | }; |
1599 | |||
1600 | static const struct v4l2_ioctl_ops vbi_ioctl_ops = { | ||
1601 | .vidioc_querycap = vidioc_querycap, | ||
1602 | .vidioc_g_fmt_vbi_cap = cx8800_vbi_fmt, | ||
1603 | .vidioc_try_fmt_vbi_cap = cx8800_vbi_fmt, | ||
1604 | .vidioc_s_fmt_vbi_cap = cx8800_vbi_fmt, | ||
1605 | .vidioc_reqbufs = vidioc_reqbufs, | ||
1606 | .vidioc_querybuf = vidioc_querybuf, | ||
1607 | .vidioc_qbuf = vidioc_qbuf, | ||
1608 | .vidioc_dqbuf = vidioc_dqbuf, | ||
1609 | .vidioc_g_std = vidioc_g_std, | ||
1610 | .vidioc_s_std = vidioc_s_std, | ||
1611 | .vidioc_enum_input = vidioc_enum_input, | ||
1612 | .vidioc_g_input = vidioc_g_input, | ||
1613 | .vidioc_s_input = vidioc_s_input, | ||
1614 | .vidioc_streamon = vidioc_streamon, | ||
1615 | .vidioc_streamoff = vidioc_streamoff, | ||
1616 | .vidioc_g_tuner = vidioc_g_tuner, | ||
1617 | .vidioc_s_tuner = vidioc_s_tuner, | ||
1618 | .vidioc_g_frequency = vidioc_g_frequency, | ||
1619 | .vidioc_s_frequency = vidioc_s_frequency, | ||
1620 | .vidioc_g_chip_ident = vidioc_g_chip_ident, | ||
1621 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1622 | .vidioc_g_register = vidioc_g_register, | ||
1623 | .vidioc_s_register = vidioc_s_register, | ||
1624 | #endif | ||
1625 | }; | ||
1626 | |||
1627 | static const struct video_device cx8800_vbi_template = { | ||
1628 | .name = "cx8800-vbi", | ||
1629 | .fops = &video_fops, | ||
1630 | .ioctl_ops = &vbi_ioctl_ops, | ||
1631 | .tvnorms = CX88_NORMS, | ||
1789 | }; | 1632 | }; |
1790 | 1633 | ||
1791 | static const struct v4l2_file_operations radio_fops = | 1634 | static const struct v4l2_file_operations radio_fops = |
1792 | { | 1635 | { |
1793 | .owner = THIS_MODULE, | 1636 | .owner = THIS_MODULE, |
1794 | .open = video_open, | 1637 | .open = video_open, |
1638 | .poll = v4l2_ctrl_poll, | ||
1795 | .release = video_release, | 1639 | .release = video_release, |
1796 | .unlocked_ioctl = video_ioctl2, | 1640 | .unlocked_ioctl = video_ioctl2, |
1797 | }; | 1641 | }; |
1798 | 1642 | ||
1799 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | 1643 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { |
1800 | .vidioc_querycap = radio_querycap, | 1644 | .vidioc_querycap = vidioc_querycap, |
1801 | .vidioc_g_tuner = radio_g_tuner, | 1645 | .vidioc_g_tuner = radio_g_tuner, |
1802 | .vidioc_enum_input = radio_enum_input, | ||
1803 | .vidioc_g_audio = radio_g_audio, | ||
1804 | .vidioc_s_tuner = radio_s_tuner, | 1646 | .vidioc_s_tuner = radio_s_tuner, |
1805 | .vidioc_s_audio = radio_s_audio, | ||
1806 | .vidioc_s_input = radio_s_input, | ||
1807 | .vidioc_queryctrl = radio_queryctrl, | ||
1808 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
1809 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
1810 | .vidioc_g_frequency = vidioc_g_frequency, | 1647 | .vidioc_g_frequency = vidioc_g_frequency, |
1811 | .vidioc_s_frequency = vidioc_s_frequency, | 1648 | .vidioc_s_frequency = vidioc_s_frequency, |
1649 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
1650 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
1651 | .vidioc_g_chip_ident = vidioc_g_chip_ident, | ||
1812 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1652 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1813 | .vidioc_g_register = vidioc_g_register, | 1653 | .vidioc_g_register = vidioc_g_register, |
1814 | .vidioc_s_register = vidioc_s_register, | 1654 | .vidioc_s_register = vidioc_s_register, |
@@ -1821,6 +1661,14 @@ static const struct video_device cx8800_radio_template = { | |||
1821 | .ioctl_ops = &radio_ioctl_ops, | 1661 | .ioctl_ops = &radio_ioctl_ops, |
1822 | }; | 1662 | }; |
1823 | 1663 | ||
1664 | static const struct v4l2_ctrl_ops cx8800_ctrl_vid_ops = { | ||
1665 | .s_ctrl = cx8800_s_vid_ctrl, | ||
1666 | }; | ||
1667 | |||
1668 | static const struct v4l2_ctrl_ops cx8800_ctrl_aud_ops = { | ||
1669 | .s_ctrl = cx8800_s_aud_ctrl, | ||
1670 | }; | ||
1671 | |||
1824 | /* ----------------------------------------------------------- */ | 1672 | /* ----------------------------------------------------------- */ |
1825 | 1673 | ||
1826 | static void cx8800_unregister_video(struct cx8800_dev *dev) | 1674 | static void cx8800_unregister_video(struct cx8800_dev *dev) |
@@ -1853,8 +1701,8 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1853 | { | 1701 | { |
1854 | struct cx8800_dev *dev; | 1702 | struct cx8800_dev *dev; |
1855 | struct cx88_core *core; | 1703 | struct cx88_core *core; |
1856 | |||
1857 | int err; | 1704 | int err; |
1705 | int i; | ||
1858 | 1706 | ||
1859 | dev = kzalloc(sizeof(*dev),GFP_KERNEL); | 1707 | dev = kzalloc(sizeof(*dev),GFP_KERNEL); |
1860 | if (NULL == dev) | 1708 | if (NULL == dev) |
@@ -1888,14 +1736,9 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1888 | goto fail_core; | 1736 | goto fail_core; |
1889 | } | 1737 | } |
1890 | 1738 | ||
1891 | /* Initialize VBI template */ | ||
1892 | memcpy( &cx8800_vbi_template, &cx8800_video_template, | ||
1893 | sizeof(cx8800_vbi_template) ); | ||
1894 | strcpy(cx8800_vbi_template.name,"cx8800-vbi"); | ||
1895 | |||
1896 | /* initialize driver struct */ | 1739 | /* initialize driver struct */ |
1897 | spin_lock_init(&dev->slock); | 1740 | spin_lock_init(&dev->slock); |
1898 | core->tvnorm = cx8800_video_template.current_norm; | 1741 | core->tvnorm = V4L2_STD_NTSC_M; |
1899 | 1742 | ||
1900 | /* init video dma queues */ | 1743 | /* init video dma queues */ |
1901 | INIT_LIST_HEAD(&dev->vidq.active); | 1744 | INIT_LIST_HEAD(&dev->vidq.active); |
@@ -1925,6 +1768,35 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1925 | } | 1768 | } |
1926 | cx_set(MO_PCI_INTMSK, core->pci_irqmask); | 1769 | cx_set(MO_PCI_INTMSK, core->pci_irqmask); |
1927 | 1770 | ||
1771 | for (i = 0; i < CX8800_AUD_CTLS; i++) { | ||
1772 | const struct cx88_ctrl *cc = &cx8800_aud_ctls[i]; | ||
1773 | struct v4l2_ctrl *vc; | ||
1774 | |||
1775 | vc = v4l2_ctrl_new_std(&core->audio_hdl, &cx8800_ctrl_aud_ops, | ||
1776 | cc->id, cc->minimum, cc->maximum, cc->step, cc->default_value); | ||
1777 | if (vc == NULL) { | ||
1778 | err = core->audio_hdl.error; | ||
1779 | goto fail_core; | ||
1780 | } | ||
1781 | vc->priv = (void *)cc; | ||
1782 | } | ||
1783 | |||
1784 | for (i = 0; i < CX8800_VID_CTLS; i++) { | ||
1785 | const struct cx88_ctrl *cc = &cx8800_vid_ctls[i]; | ||
1786 | struct v4l2_ctrl *vc; | ||
1787 | |||
1788 | vc = v4l2_ctrl_new_std(&core->video_hdl, &cx8800_ctrl_vid_ops, | ||
1789 | cc->id, cc->minimum, cc->maximum, cc->step, cc->default_value); | ||
1790 | if (vc == NULL) { | ||
1791 | err = core->video_hdl.error; | ||
1792 | goto fail_core; | ||
1793 | } | ||
1794 | vc->priv = (void *)cc; | ||
1795 | if (vc->id == V4L2_CID_CHROMA_AGC) | ||
1796 | core->chroma_agc = vc; | ||
1797 | } | ||
1798 | v4l2_ctrl_add_handler(&core->video_hdl, &core->audio_hdl); | ||
1799 | |||
1928 | /* load and configure helper modules */ | 1800 | /* load and configure helper modules */ |
1929 | 1801 | ||
1930 | if (core->board.audio_chip == V4L2_IDENT_WM8775) { | 1802 | if (core->board.audio_chip == V4L2_IDENT_WM8775) { |
@@ -1942,8 +1814,10 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1942 | 1814 | ||
1943 | sd = v4l2_i2c_new_subdev_board(&core->v4l2_dev, &core->i2c_adap, | 1815 | sd = v4l2_i2c_new_subdev_board(&core->v4l2_dev, &core->i2c_adap, |
1944 | &wm8775_info, NULL); | 1816 | &wm8775_info, NULL); |
1945 | if (sd != NULL) | 1817 | if (sd != NULL) { |
1818 | core->sd_wm8775 = sd; | ||
1946 | sd->grp_id = WM8775_GID; | 1819 | sd->grp_id = WM8775_GID; |
1820 | } | ||
1947 | } | 1821 | } |
1948 | 1822 | ||
1949 | if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) { | 1823 | if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) { |
@@ -1971,16 +1845,22 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1971 | /* Sets device info at pci_dev */ | 1845 | /* Sets device info at pci_dev */ |
1972 | pci_set_drvdata(pci_dev, dev); | 1846 | pci_set_drvdata(pci_dev, dev); |
1973 | 1847 | ||
1848 | dev->width = 320; | ||
1849 | dev->height = 240; | ||
1850 | dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); | ||
1851 | |||
1974 | /* initial device configuration */ | 1852 | /* initial device configuration */ |
1975 | mutex_lock(&core->lock); | 1853 | mutex_lock(&core->lock); |
1976 | cx88_set_tvnorm(core, core->tvnorm); | 1854 | cx88_set_tvnorm(core, core->tvnorm); |
1977 | init_controls(core); | 1855 | v4l2_ctrl_handler_setup(&core->video_hdl); |
1856 | v4l2_ctrl_handler_setup(&core->audio_hdl); | ||
1978 | cx88_video_mux(core, 0); | 1857 | cx88_video_mux(core, 0); |
1979 | 1858 | ||
1980 | /* register v4l devices */ | 1859 | /* register v4l devices */ |
1981 | dev->video_dev = cx88_vdev_init(core,dev->pci, | 1860 | dev->video_dev = cx88_vdev_init(core,dev->pci, |
1982 | &cx8800_video_template,"video"); | 1861 | &cx8800_video_template,"video"); |
1983 | video_set_drvdata(dev->video_dev, dev); | 1862 | video_set_drvdata(dev->video_dev, dev); |
1863 | dev->video_dev->ctrl_handler = &core->video_hdl; | ||
1984 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, | 1864 | err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER, |
1985 | video_nr[core->nr]); | 1865 | video_nr[core->nr]); |
1986 | if (err < 0) { | 1866 | if (err < 0) { |
@@ -2007,6 +1887,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
2007 | dev->radio_dev = cx88_vdev_init(core,dev->pci, | 1887 | dev->radio_dev = cx88_vdev_init(core,dev->pci, |
2008 | &cx8800_radio_template,"radio"); | 1888 | &cx8800_radio_template,"radio"); |
2009 | video_set_drvdata(dev->radio_dev, dev); | 1889 | video_set_drvdata(dev->radio_dev, dev); |
1890 | dev->radio_dev->ctrl_handler = &core->audio_hdl; | ||
2010 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, | 1891 | err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO, |
2011 | radio_nr[core->nr]); | 1892 | radio_nr[core->nr]); |
2012 | if (err < 0) { | 1893 | if (err < 0) { |
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index c9659def2a78..0cae0fd9e164 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/kdev_t.h> | 26 | #include <linux/kdev_t.h> |
27 | 27 | ||
28 | #include <media/v4l2-device.h> | 28 | #include <media/v4l2-device.h> |
29 | #include <media/v4l2-fh.h> | ||
29 | #include <media/tuner.h> | 30 | #include <media/tuner.h> |
30 | #include <media/tveeprom.h> | 31 | #include <media/tveeprom.h> |
31 | #include <media/videobuf-dma-sg.h> | 32 | #include <media/videobuf-dma-sg.h> |
@@ -115,15 +116,6 @@ struct cx8800_fmt { | |||
115 | u32 cxformat; | 116 | u32 cxformat; |
116 | }; | 117 | }; |
117 | 118 | ||
118 | struct cx88_ctrl { | ||
119 | struct v4l2_queryctrl v; | ||
120 | u32 off; | ||
121 | u32 reg; | ||
122 | u32 sreg; | ||
123 | u32 mask; | ||
124 | u32 shift; | ||
125 | }; | ||
126 | |||
127 | /* ----------------------------------------------------------- */ | 119 | /* ----------------------------------------------------------- */ |
128 | /* SRAM memory management data (see cx88-core.c) */ | 120 | /* SRAM memory management data (see cx88-core.c) */ |
129 | 121 | ||
@@ -359,6 +351,10 @@ struct cx88_core { | |||
359 | 351 | ||
360 | /* config info -- analog */ | 352 | /* config info -- analog */ |
361 | struct v4l2_device v4l2_dev; | 353 | struct v4l2_device v4l2_dev; |
354 | struct v4l2_ctrl_handler video_hdl; | ||
355 | struct v4l2_ctrl *chroma_agc; | ||
356 | struct v4l2_ctrl_handler audio_hdl; | ||
357 | struct v4l2_subdev *sd_wm8775; | ||
362 | struct i2c_client *i2c_rtc; | 358 | struct i2c_client *i2c_rtc; |
363 | unsigned int boardnr; | 359 | unsigned int boardnr; |
364 | struct cx88_board board; | 360 | struct cx88_board board; |
@@ -409,8 +405,6 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) | |||
409 | return container_of(v4l2_dev, struct cx88_core, v4l2_dev); | 405 | return container_of(v4l2_dev, struct cx88_core, v4l2_dev); |
410 | } | 406 | } |
411 | 407 | ||
412 | #define WM8775_GID (1 << 0) | ||
413 | |||
414 | #define call_hw(core, grpid, o, f, args...) \ | 408 | #define call_hw(core, grpid, o, f, args...) \ |
415 | do { \ | 409 | do { \ |
416 | if (!core->i2c_rc) { \ | 410 | if (!core->i2c_rc) { \ |
@@ -424,6 +418,36 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) | |||
424 | 418 | ||
425 | #define call_all(core, o, f, args...) call_hw(core, 0, o, f, ##args) | 419 | #define call_all(core, o, f, args...) call_hw(core, 0, o, f, ##args) |
426 | 420 | ||
421 | #define WM8775_GID (1 << 0) | ||
422 | |||
423 | #define wm8775_s_ctrl(core, id, val) \ | ||
424 | do { \ | ||
425 | struct v4l2_ctrl *ctrl_ = \ | ||
426 | v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id); \ | ||
427 | if (ctrl_ && !core->i2c_rc) { \ | ||
428 | if (core->gate_ctrl) \ | ||
429 | core->gate_ctrl(core, 1); \ | ||
430 | v4l2_ctrl_s_ctrl(ctrl_, val); \ | ||
431 | if (core->gate_ctrl) \ | ||
432 | core->gate_ctrl(core, 0); \ | ||
433 | } \ | ||
434 | } while (0) | ||
435 | |||
436 | #define wm8775_g_ctrl(core, id) \ | ||
437 | ({ \ | ||
438 | struct v4l2_ctrl *ctrl_ = \ | ||
439 | v4l2_ctrl_find(core->sd_wm8775->ctrl_handler, id); \ | ||
440 | s32 val = 0; \ | ||
441 | if (ctrl_ && !core->i2c_rc) { \ | ||
442 | if (core->gate_ctrl) \ | ||
443 | core->gate_ctrl(core, 1); \ | ||
444 | val = v4l2_ctrl_g_ctrl(ctrl_); \ | ||
445 | if (core->gate_ctrl) \ | ||
446 | core->gate_ctrl(core, 0); \ | ||
447 | } \ | ||
448 | val; \ | ||
449 | }) | ||
450 | |||
427 | struct cx8800_dev; | 451 | struct cx8800_dev; |
428 | struct cx8802_dev; | 452 | struct cx8802_dev; |
429 | 453 | ||
@@ -431,19 +455,11 @@ struct cx8802_dev; | |||
431 | /* function 0: video stuff */ | 455 | /* function 0: video stuff */ |
432 | 456 | ||
433 | struct cx8800_fh { | 457 | struct cx8800_fh { |
458 | struct v4l2_fh fh; | ||
434 | struct cx8800_dev *dev; | 459 | struct cx8800_dev *dev; |
435 | enum v4l2_buf_type type; | ||
436 | int radio; | ||
437 | unsigned int resources; | 460 | unsigned int resources; |
438 | 461 | ||
439 | /* video overlay */ | ||
440 | struct v4l2_window win; | ||
441 | struct v4l2_clip *clips; | ||
442 | unsigned int nclips; | ||
443 | |||
444 | /* video capture */ | 462 | /* video capture */ |
445 | const struct cx8800_fmt *fmt; | ||
446 | unsigned int width,height; | ||
447 | struct videobuf_queue vidq; | 463 | struct videobuf_queue vidq; |
448 | 464 | ||
449 | /* vbi capture */ | 465 | /* vbi capture */ |
@@ -468,6 +484,8 @@ struct cx8800_dev { | |||
468 | struct pci_dev *pci; | 484 | struct pci_dev *pci; |
469 | unsigned char pci_rev,pci_lat; | 485 | unsigned char pci_rev,pci_lat; |
470 | 486 | ||
487 | const struct cx8800_fmt *fmt; | ||
488 | unsigned int width, height; | ||
471 | 489 | ||
472 | /* capture queues */ | 490 | /* capture queues */ |
473 | struct cx88_dmaqueue vidq; | 491 | struct cx88_dmaqueue vidq; |
@@ -488,6 +506,7 @@ struct cx8800_dev { | |||
488 | /* function 2: mpeg stuff */ | 506 | /* function 2: mpeg stuff */ |
489 | 507 | ||
490 | struct cx8802_fh { | 508 | struct cx8802_fh { |
509 | struct v4l2_fh fh; | ||
491 | struct cx8802_dev *dev; | 510 | struct cx8802_dev *dev; |
492 | struct videobuf_queue mpegq; | 511 | struct videobuf_queue mpegq; |
493 | }; | 512 | }; |
@@ -552,7 +571,7 @@ struct cx8802_dev { | |||
552 | unsigned char mpeg_active; /* nonzero if mpeg encoder is active */ | 571 | unsigned char mpeg_active; /* nonzero if mpeg encoder is active */ |
553 | 572 | ||
554 | /* mpeg params */ | 573 | /* mpeg params */ |
555 | struct cx2341x_mpeg_params params; | 574 | struct cx2341x_handler cxhdl; |
556 | #endif | 575 | #endif |
557 | 576 | ||
558 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) | 577 | #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) |
@@ -722,11 +741,8 @@ void cx8802_cancel_buffers(struct cx8802_dev *dev); | |||
722 | 741 | ||
723 | /* ----------------------------------------------------------- */ | 742 | /* ----------------------------------------------------------- */ |
724 | /* cx88-video.c*/ | 743 | /* cx88-video.c*/ |
725 | extern const u32 cx88_user_ctrls[]; | ||
726 | extern int cx8800_ctrl_query(struct cx88_core *core, | ||
727 | struct v4l2_queryctrl *qctrl); | ||
728 | int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i); | 744 | int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i); |
729 | int cx88_set_freq (struct cx88_core *core,struct v4l2_frequency *f); | 745 | int cx88_set_freq (struct cx88_core *core,struct v4l2_frequency *f); |
730 | int cx88_get_control(struct cx88_core *core, struct v4l2_control *ctl); | ||
731 | int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl); | ||
732 | int cx88_video_mux(struct cx88_core *core, unsigned int input); | 746 | int cx88_video_mux(struct cx88_core *core, unsigned int input); |
747 | void cx88_querycap(struct file *file, struct cx88_core *core, | ||
748 | struct v4l2_capability *cap); | ||
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index d7e2a3dc5525..07dc594e79f0 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <sound/initval.h> | 42 | #include <sound/initval.h> |
43 | #include <sound/control.h> | 43 | #include <sound/control.h> |
44 | #include <sound/tlv.h> | 44 | #include <sound/tlv.h> |
45 | #include <sound/ac97_codec.h> | ||
45 | #include <media/v4l2-common.h> | 46 | #include <media/v4l2-common.h> |
46 | #include "em28xx.h" | 47 | #include "em28xx.h" |
47 | 48 | ||
@@ -679,19 +680,19 @@ static int em28xx_audio_init(struct em28xx *dev) | |||
679 | INIT_WORK(&dev->wq_trigger, audio_trigger); | 680 | INIT_WORK(&dev->wq_trigger, audio_trigger); |
680 | 681 | ||
681 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { | 682 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { |
682 | em28xx_cvol_new(card, dev, "Video", AC97_VIDEO_VOL); | 683 | em28xx_cvol_new(card, dev, "Video", AC97_VIDEO); |
683 | em28xx_cvol_new(card, dev, "Line In", AC97_LINEIN_VOL); | 684 | em28xx_cvol_new(card, dev, "Line In", AC97_LINE); |
684 | em28xx_cvol_new(card, dev, "Phone", AC97_PHONE_VOL); | 685 | em28xx_cvol_new(card, dev, "Phone", AC97_PHONE); |
685 | em28xx_cvol_new(card, dev, "Microphone", AC97_PHONE_VOL); | 686 | em28xx_cvol_new(card, dev, "Microphone", AC97_MIC); |
686 | em28xx_cvol_new(card, dev, "CD", AC97_CD_VOL); | 687 | em28xx_cvol_new(card, dev, "CD", AC97_CD); |
687 | em28xx_cvol_new(card, dev, "AUX", AC97_AUX_VOL); | 688 | em28xx_cvol_new(card, dev, "AUX", AC97_AUX); |
688 | em28xx_cvol_new(card, dev, "PCM", AC97_PCM_OUT_VOL); | 689 | em28xx_cvol_new(card, dev, "PCM", AC97_PCM); |
689 | 690 | ||
690 | em28xx_cvol_new(card, dev, "Master", AC97_MASTER_VOL); | 691 | em28xx_cvol_new(card, dev, "Master", AC97_MASTER); |
691 | em28xx_cvol_new(card, dev, "Line", AC97_LINE_LEVEL_VOL); | 692 | em28xx_cvol_new(card, dev, "Line", AC97_HEADPHONE); |
692 | em28xx_cvol_new(card, dev, "Mono", AC97_MASTER_MONO_VOL); | 693 | em28xx_cvol_new(card, dev, "Mono", AC97_MASTER_MONO); |
693 | em28xx_cvol_new(card, dev, "LFE", AC97_LFE_MASTER_VOL); | 694 | em28xx_cvol_new(card, dev, "LFE", AC97_CENTER_LFE_MASTER); |
694 | em28xx_cvol_new(card, dev, "Surround", AC97_SURR_MASTER_VOL); | 695 | em28xx_cvol_new(card, dev, "Surround", AC97_SURROUND_MASTER); |
695 | } | 696 | } |
696 | 697 | ||
697 | err = snd_card_register(card); | 698 | err = snd_card_register(card); |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 862c6575c557..ca62b9981380 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -975,12 +975,7 @@ struct em28xx_board em28xx_boards[] = { | |||
975 | .name = "Terratec Cinergy HTC Stick", | 975 | .name = "Terratec Cinergy HTC Stick", |
976 | .has_dvb = 1, | 976 | .has_dvb = 1, |
977 | .ir_codes = RC_MAP_NEC_TERRATEC_CINERGY_XS, | 977 | .ir_codes = RC_MAP_NEC_TERRATEC_CINERGY_XS, |
978 | #if 0 | 978 | .tuner_type = TUNER_ABSENT, |
979 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
980 | .tuner_addr = 0x41, | ||
981 | .dvb_gpio = terratec_h5_digital, /* FIXME: probably wrong */ | ||
982 | .tuner_gpio = terratec_h5_gpio, | ||
983 | #endif | ||
984 | .i2c_speed = EM2874_I2C_SECONDARY_BUS_SELECT | | 979 | .i2c_speed = EM2874_I2C_SECONDARY_BUS_SELECT | |
985 | EM28XX_I2C_CLK_WAIT_ENABLE | | 980 | EM28XX_I2C_CLK_WAIT_ENABLE | |
986 | EM28XX_I2C_FREQ_400_KHZ, | 981 | EM28XX_I2C_FREQ_400_KHZ, |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 5717bdee8f1b..de2cb20ad2cc 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/usb.h> | 28 | #include <linux/usb.h> |
29 | #include <linux/vmalloc.h> | 29 | #include <linux/vmalloc.h> |
30 | #include <sound/ac97_codec.h> | ||
30 | #include <media/v4l2-common.h> | 31 | #include <media/v4l2-common.h> |
31 | 32 | ||
32 | #include "em28xx.h" | 33 | #include "em28xx.h" |
@@ -326,13 +327,13 @@ struct em28xx_vol_itable { | |||
326 | }; | 327 | }; |
327 | 328 | ||
328 | static struct em28xx_vol_itable inputs[] = { | 329 | static struct em28xx_vol_itable inputs[] = { |
329 | { EM28XX_AMUX_VIDEO, AC97_VIDEO_VOL }, | 330 | { EM28XX_AMUX_VIDEO, AC97_VIDEO }, |
330 | { EM28XX_AMUX_LINE_IN, AC97_LINEIN_VOL }, | 331 | { EM28XX_AMUX_LINE_IN, AC97_LINE }, |
331 | { EM28XX_AMUX_PHONE, AC97_PHONE_VOL }, | 332 | { EM28XX_AMUX_PHONE, AC97_PHONE }, |
332 | { EM28XX_AMUX_MIC, AC97_MIC_VOL }, | 333 | { EM28XX_AMUX_MIC, AC97_MIC }, |
333 | { EM28XX_AMUX_CD, AC97_CD_VOL }, | 334 | { EM28XX_AMUX_CD, AC97_CD }, |
334 | { EM28XX_AMUX_AUX, AC97_AUX_VOL }, | 335 | { EM28XX_AMUX_AUX, AC97_AUX }, |
335 | { EM28XX_AMUX_PCM_OUT, AC97_PCM_OUT_VOL }, | 336 | { EM28XX_AMUX_PCM_OUT, AC97_PCM }, |
336 | }; | 337 | }; |
337 | 338 | ||
338 | static int set_ac97_input(struct em28xx *dev) | 339 | static int set_ac97_input(struct em28xx *dev) |
@@ -415,11 +416,11 @@ struct em28xx_vol_otable { | |||
415 | }; | 416 | }; |
416 | 417 | ||
417 | static const struct em28xx_vol_otable outputs[] = { | 418 | static const struct em28xx_vol_otable outputs[] = { |
418 | { EM28XX_AOUT_MASTER, AC97_MASTER_VOL }, | 419 | { EM28XX_AOUT_MASTER, AC97_MASTER }, |
419 | { EM28XX_AOUT_LINE, AC97_LINE_LEVEL_VOL }, | 420 | { EM28XX_AOUT_LINE, AC97_HEADPHONE }, |
420 | { EM28XX_AOUT_MONO, AC97_MASTER_MONO_VOL }, | 421 | { EM28XX_AOUT_MONO, AC97_MASTER_MONO }, |
421 | { EM28XX_AOUT_LFE, AC97_LFE_MASTER_VOL }, | 422 | { EM28XX_AOUT_LFE, AC97_CENTER_LFE_MASTER }, |
422 | { EM28XX_AOUT_SURR, AC97_SURR_MASTER_VOL }, | 423 | { EM28XX_AOUT_SURR, AC97_SURROUND_MASTER }, |
423 | }; | 424 | }; |
424 | 425 | ||
425 | int em28xx_audio_analog_set(struct em28xx *dev) | 426 | int em28xx_audio_analog_set(struct em28xx *dev) |
@@ -459,9 +460,9 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
459 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { | 460 | if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { |
460 | int vol; | 461 | int vol; |
461 | 462 | ||
462 | em28xx_write_ac97(dev, AC97_POWER_DOWN_CTRL, 0x4200); | 463 | em28xx_write_ac97(dev, AC97_POWERDOWN, 0x4200); |
463 | em28xx_write_ac97(dev, AC97_EXT_AUD_CTRL, 0x0031); | 464 | em28xx_write_ac97(dev, AC97_EXTENDED_STATUS, 0x0031); |
464 | em28xx_write_ac97(dev, AC97_PCM_IN_SRATE, 0xbb80); | 465 | em28xx_write_ac97(dev, AC97_PCM_LR_ADC_RATE, 0xbb80); |
465 | 466 | ||
466 | /* LSB: left channel - both channels with the same level */ | 467 | /* LSB: left channel - both channels with the same level */ |
467 | vol = (0x1f - dev->volume) | ((0x1f - dev->volume) << 8); | 468 | vol = (0x1f - dev->volume) | ((0x1f - dev->volume) << 8); |
@@ -487,7 +488,7 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
487 | channels */ | 488 | channels */ |
488 | sel |= (sel << 8); | 489 | sel |= (sel << 8); |
489 | 490 | ||
490 | em28xx_write_ac97(dev, AC97_RECORD_SELECT, sel); | 491 | em28xx_write_ac97(dev, AC97_REC_SEL, sel); |
491 | } | 492 | } |
492 | } | 493 | } |
493 | 494 | ||
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c index 16410ac20092..a16531fa937a 100644 --- a/drivers/media/video/em28xx/em28xx-dvb.c +++ b/drivers/media/video/em28xx/em28xx-dvb.c | |||
@@ -310,31 +310,47 @@ static struct drxd_config em28xx_drxd = { | |||
310 | .disable_i2c_gate_ctrl = 1, | 310 | .disable_i2c_gate_ctrl = 1, |
311 | }; | 311 | }; |
312 | 312 | ||
313 | struct drxk_config terratec_h5_drxk = { | 313 | static struct drxk_config terratec_h5_drxk = { |
314 | .adr = 0x29, | 314 | .adr = 0x29, |
315 | .single_master = 1, | 315 | .single_master = 1, |
316 | .no_i2c_bridge = 1, | 316 | .no_i2c_bridge = 1, |
317 | .microcode_name = "dvb-usb-terratec-h5-drxk.fw", | 317 | .microcode_name = "dvb-usb-terratec-h5-drxk.fw", |
318 | .qam_demod_parameter_count = 2, | ||
318 | }; | 319 | }; |
319 | 320 | ||
320 | struct drxk_config hauppauge_930c_drxk = { | 321 | static struct drxk_config hauppauge_930c_drxk = { |
321 | .adr = 0x29, | 322 | .adr = 0x29, |
322 | .single_master = 1, | 323 | .single_master = 1, |
323 | .no_i2c_bridge = 1, | 324 | .no_i2c_bridge = 1, |
324 | .microcode_name = "dvb-usb-hauppauge-hvr930c-drxk.fw", | 325 | .microcode_name = "dvb-usb-hauppauge-hvr930c-drxk.fw", |
325 | .chunk_size = 56, | 326 | .chunk_size = 56, |
327 | .qam_demod_parameter_count = 2, | ||
326 | }; | 328 | }; |
327 | 329 | ||
328 | struct drxk_config maxmedia_ub425_tc_drxk = { | 330 | struct drxk_config terratec_htc_stick_drxk = { |
329 | .adr = 0x29, | 331 | .adr = 0x29, |
330 | .single_master = 1, | 332 | .single_master = 1, |
331 | .no_i2c_bridge = 1, | 333 | .no_i2c_bridge = 1, |
334 | .microcode_name = "dvb-usb-terratec-htc-stick-drxk.fw", | ||
335 | .chunk_size = 54, | ||
336 | .qam_demod_parameter_count = 2, | ||
337 | /* Required for the antenna_gpio to disable LNA. */ | ||
338 | .antenna_dvbt = true, | ||
339 | /* The windows driver uses the same. This will disable LNA. */ | ||
340 | .antenna_gpio = 0x6, | ||
332 | }; | 341 | }; |
333 | 342 | ||
334 | struct drxk_config pctv_520e_drxk = { | 343 | static struct drxk_config maxmedia_ub425_tc_drxk = { |
344 | .adr = 0x29, | ||
345 | .single_master = 1, | ||
346 | .no_i2c_bridge = 1, | ||
347 | }; | ||
348 | |||
349 | static struct drxk_config pctv_520e_drxk = { | ||
335 | .adr = 0x29, | 350 | .adr = 0x29, |
336 | .single_master = 1, | 351 | .single_master = 1, |
337 | .microcode_name = "dvb-demod-drxk-pctv.fw", | 352 | .microcode_name = "dvb-demod-drxk-pctv.fw", |
353 | .qam_demod_parameter_count = 2, | ||
338 | .chunk_size = 58, | 354 | .chunk_size = 58, |
339 | .antenna_dvbt = true, /* disable LNA */ | 355 | .antenna_dvbt = true, /* disable LNA */ |
340 | .antenna_gpio = (1 << 2), /* disable LNA */ | 356 | .antenna_gpio = (1 << 2), /* disable LNA */ |
@@ -473,6 +489,57 @@ static void terratec_h5_init(struct em28xx *dev) | |||
473 | em28xx_gpio_set(dev, terratec_h5_end); | 489 | em28xx_gpio_set(dev, terratec_h5_end); |
474 | }; | 490 | }; |
475 | 491 | ||
492 | static void terratec_htc_stick_init(struct em28xx *dev) | ||
493 | { | ||
494 | int i; | ||
495 | |||
496 | /* | ||
497 | * GPIO configuration: | ||
498 | * 0xff: unknown (does not affect DVB-T). | ||
499 | * 0xf6: DRX-K (demodulator). | ||
500 | * 0xe6: unknown (does not affect DVB-T). | ||
501 | * 0xb6: unknown (does not affect DVB-T). | ||
502 | */ | ||
503 | struct em28xx_reg_seq terratec_htc_stick_init[] = { | ||
504 | {EM28XX_R08_GPIO, 0xff, 0xff, 10}, | ||
505 | {EM2874_R80_GPIO, 0xf6, 0xff, 100}, | ||
506 | {EM2874_R80_GPIO, 0xe6, 0xff, 50}, | ||
507 | {EM2874_R80_GPIO, 0xf6, 0xff, 100}, | ||
508 | { -1, -1, -1, -1}, | ||
509 | }; | ||
510 | struct em28xx_reg_seq terratec_htc_stick_end[] = { | ||
511 | {EM2874_R80_GPIO, 0xb6, 0xff, 100}, | ||
512 | {EM2874_R80_GPIO, 0xf6, 0xff, 50}, | ||
513 | { -1, -1, -1, -1}, | ||
514 | }; | ||
515 | |||
516 | /* Init the analog decoder? */ | ||
517 | struct { | ||
518 | unsigned char r[4]; | ||
519 | int len; | ||
520 | } regs[] = { | ||
521 | {{ 0x06, 0x02, 0x00, 0x31 }, 4}, | ||
522 | {{ 0x01, 0x02 }, 2}, | ||
523 | {{ 0x01, 0x02, 0x00, 0xc6 }, 4}, | ||
524 | {{ 0x01, 0x00 }, 2}, | ||
525 | {{ 0x01, 0x00, 0xff, 0xaf }, 4}, | ||
526 | }; | ||
527 | |||
528 | em28xx_gpio_set(dev, terratec_htc_stick_init); | ||
529 | |||
530 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40); | ||
531 | msleep(10); | ||
532 | em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x44); | ||
533 | msleep(10); | ||
534 | |||
535 | dev->i2c_client.addr = 0x82 >> 1; | ||
536 | |||
537 | for (i = 0; i < ARRAY_SIZE(regs); i++) | ||
538 | i2c_master_send(&dev->i2c_client, regs[i].r, regs[i].len); | ||
539 | |||
540 | em28xx_gpio_set(dev, terratec_htc_stick_end); | ||
541 | }; | ||
542 | |||
476 | static void pctv_520e_init(struct em28xx *dev) | 543 | static void pctv_520e_init(struct em28xx *dev) |
477 | { | 544 | { |
478 | /* | 545 | /* |
@@ -944,7 +1011,6 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
944 | break; | 1011 | break; |
945 | } | 1012 | } |
946 | case EM2884_BOARD_TERRATEC_H5: | 1013 | case EM2884_BOARD_TERRATEC_H5: |
947 | case EM2884_BOARD_CINERGY_HTC_STICK: | ||
948 | terratec_h5_init(dev); | 1014 | terratec_h5_init(dev); |
949 | 1015 | ||
950 | dvb->fe[0] = dvb_attach(drxk_attach, &terratec_h5_drxk, &dev->i2c_adap); | 1016 | dvb->fe[0] = dvb_attach(drxk_attach, &terratec_h5_drxk, &dev->i2c_adap); |
@@ -1021,6 +1087,25 @@ static int em28xx_dvb_init(struct em28xx *dev) | |||
1021 | } | 1087 | } |
1022 | } | 1088 | } |
1023 | break; | 1089 | break; |
1090 | case EM2884_BOARD_CINERGY_HTC_STICK: | ||
1091 | terratec_htc_stick_init(dev); | ||
1092 | |||
1093 | /* attach demodulator */ | ||
1094 | dvb->fe[0] = dvb_attach(drxk_attach, &terratec_htc_stick_drxk, | ||
1095 | &dev->i2c_adap); | ||
1096 | if (!dvb->fe[0]) { | ||
1097 | result = -EINVAL; | ||
1098 | goto out_free; | ||
1099 | } | ||
1100 | |||
1101 | /* Attach the demodulator. */ | ||
1102 | if (!dvb_attach(tda18271_attach, dvb->fe[0], 0x60, | ||
1103 | &dev->i2c_adap, | ||
1104 | &em28xx_cxd2820r_tda18271_config)) { | ||
1105 | result = -EINVAL; | ||
1106 | goto out_free; | ||
1107 | } | ||
1108 | break; | ||
1024 | default: | 1109 | default: |
1025 | em28xx_errdev("/2: The frontend of your DVB/ATSC card" | 1110 | em28xx_errdev("/2: The frontend of your DVB/ATSC card" |
1026 | " isn't supported yet\n"); | 1111 | " isn't supported yet\n"); |
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c index 185db65b766e..1683bd9d51ee 100644 --- a/drivers/media/video/em28xx/em28xx-i2c.c +++ b/drivers/media/video/em28xx/em28xx-i2c.c | |||
@@ -475,6 +475,7 @@ static struct i2c_client em28xx_client_template = { | |||
475 | */ | 475 | */ |
476 | static char *i2c_devs[128] = { | 476 | static char *i2c_devs[128] = { |
477 | [0x4a >> 1] = "saa7113h", | 477 | [0x4a >> 1] = "saa7113h", |
478 | [0x52 >> 1] = "drxk", | ||
478 | [0x60 >> 1] = "remote IR sensor", | 479 | [0x60 >> 1] = "remote IR sensor", |
479 | [0x8e >> 1] = "remote IR sensor", | 480 | [0x8e >> 1] = "remote IR sensor", |
480 | [0x86 >> 1] = "tda9887", | 481 | [0x86 >> 1] = "tda9887", |
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c index 5e30c4f3f248..97d36b4f19db 100644 --- a/drivers/media/video/em28xx/em28xx-input.c +++ b/drivers/media/video/em28xx/em28xx-input.c | |||
@@ -345,7 +345,7 @@ static void em28xx_ir_stop(struct rc_dev *rc) | |||
345 | cancel_delayed_work_sync(&ir->work); | 345 | cancel_delayed_work_sync(&ir->work); |
346 | } | 346 | } |
347 | 347 | ||
348 | int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 rc_type) | 348 | static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 rc_type) |
349 | { | 349 | { |
350 | int rc = 0; | 350 | int rc = 0; |
351 | struct em28xx_IR *ir = rc_dev->priv; | 351 | struct em28xx_IR *ir = rc_dev->priv; |
diff --git a/drivers/media/video/em28xx/em28xx-reg.h b/drivers/media/video/em28xx/em28xx-reg.h index 2f6268505726..6ff368297f6e 100644 --- a/drivers/media/video/em28xx/em28xx-reg.h +++ b/drivers/media/video/em28xx/em28xx-reg.h | |||
@@ -211,58 +211,9 @@ enum em28xx_chip_id { | |||
211 | }; | 211 | }; |
212 | 212 | ||
213 | /* | 213 | /* |
214 | * Registers used by em202 and other AC97 chips | 214 | * Registers used by em202 |
215 | */ | 215 | */ |
216 | 216 | ||
217 | /* Standard AC97 registers */ | ||
218 | #define AC97_RESET 0x00 | ||
219 | |||
220 | /* Output volumes */ | ||
221 | #define AC97_MASTER_VOL 0x02 | ||
222 | #define AC97_LINE_LEVEL_VOL 0x04 /* Some devices use for headphones */ | ||
223 | #define AC97_MASTER_MONO_VOL 0x06 | ||
224 | |||
225 | /* Input volumes */ | ||
226 | #define AC97_PC_BEEP_VOL 0x0a | ||
227 | #define AC97_PHONE_VOL 0x0c | ||
228 | #define AC97_MIC_VOL 0x0e | ||
229 | #define AC97_LINEIN_VOL 0x10 | ||
230 | #define AC97_CD_VOL 0x12 | ||
231 | #define AC97_VIDEO_VOL 0x14 | ||
232 | #define AC97_AUX_VOL 0x16 | ||
233 | #define AC97_PCM_OUT_VOL 0x18 | ||
234 | |||
235 | /* capture registers */ | ||
236 | #define AC97_RECORD_SELECT 0x1a | ||
237 | #define AC97_RECORD_GAIN 0x1c | ||
238 | |||
239 | /* control registers */ | ||
240 | #define AC97_GENERAL_PURPOSE 0x20 | ||
241 | #define AC97_3D_CTRL 0x22 | ||
242 | #define AC97_AUD_INT_AND_PAG 0x24 | ||
243 | #define AC97_POWER_DOWN_CTRL 0x26 | ||
244 | #define AC97_EXT_AUD_ID 0x28 | ||
245 | #define AC97_EXT_AUD_CTRL 0x2a | ||
246 | |||
247 | /* Supported rate varies for each AC97 device | ||
248 | if write an unsupported value, it will return the closest one | ||
249 | */ | ||
250 | #define AC97_PCM_OUT_FRONT_SRATE 0x2c | ||
251 | #define AC97_PCM_OUT_SURR_SRATE 0x2e | ||
252 | #define AC97_PCM_OUT_LFE_SRATE 0x30 | ||
253 | #define AC97_PCM_IN_SRATE 0x32 | ||
254 | |||
255 | /* For devices with more than 2 channels, extra output volumes */ | ||
256 | #define AC97_LFE_MASTER_VOL 0x36 | ||
257 | #define AC97_SURR_MASTER_VOL 0x38 | ||
258 | |||
259 | /* Digital SPDIF output control */ | ||
260 | #define AC97_SPDIF_OUT_CTRL 0x3a | ||
261 | |||
262 | /* Vendor ID identifier */ | ||
263 | #define AC97_VENDOR_ID1 0x7c | ||
264 | #define AC97_VENDOR_ID2 0x7e | ||
265 | |||
266 | /* EMP202 vendor registers */ | 217 | /* EMP202 vendor registers */ |
267 | #define EM202_EXT_MODEM_CTRL 0x3e | 218 | #define EM202_EXT_MODEM_CTRL 0x3e |
268 | #define EM202_GPIO_CONF 0x4c | 219 | #define EM202_GPIO_CONF 0x4c |
diff --git a/drivers/media/video/ibmmpeg2.h b/drivers/media/video/ibmmpeg2.h deleted file mode 100644 index 68e10387c498..000000000000 --- a/drivers/media/video/ibmmpeg2.h +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | /* ibmmpeg2.h - IBM MPEGCD21 definitions */ | ||
2 | |||
3 | #ifndef __IBM_MPEG2__ | ||
4 | #define __IBM_MPEG2__ | ||
5 | |||
6 | /* Define all MPEG Decoder registers */ | ||
7 | /* Chip Control and Status */ | ||
8 | #define IBM_MP2_CHIP_CONTROL 0x200*2 | ||
9 | #define IBM_MP2_CHIP_MODE 0x201*2 | ||
10 | /* Timer Control and Status */ | ||
11 | #define IBM_MP2_SYNC_STC2 0x202*2 | ||
12 | #define IBM_MP2_SYNC_STC1 0x203*2 | ||
13 | #define IBM_MP2_SYNC_STC0 0x204*2 | ||
14 | #define IBM_MP2_SYNC_PTS2 0x205*2 | ||
15 | #define IBM_MP2_SYNC_PTS1 0x206*2 | ||
16 | #define IBM_MP2_SYNC_PTS0 0x207*2 | ||
17 | /* Video FIFO Control */ | ||
18 | #define IBM_MP2_FIFO 0x208*2 | ||
19 | #define IBM_MP2_FIFOW 0x100*2 | ||
20 | #define IBM_MP2_FIFO_STAT 0x209*2 | ||
21 | #define IBM_MP2_RB_THRESHOLD 0x22b*2 | ||
22 | /* Command buffer */ | ||
23 | #define IBM_MP2_COMMAND 0x20a*2 | ||
24 | #define IBM_MP2_CMD_DATA 0x20b*2 | ||
25 | #define IBM_MP2_CMD_STAT 0x20c*2 | ||
26 | #define IBM_MP2_CMD_ADDR 0x20d*2 | ||
27 | /* Internal Processor Control and Status */ | ||
28 | #define IBM_MP2_PROC_IADDR 0x20e*2 | ||
29 | #define IBM_MP2_PROC_IDATA 0x20f*2 | ||
30 | #define IBM_MP2_WR_PROT 0x235*2 | ||
31 | /* DRAM Access */ | ||
32 | #define IBM_MP2_DRAM_ADDR 0x210*2 | ||
33 | #define IBM_MP2_DRAM_DATA 0x212*2 | ||
34 | #define IBM_MP2_DRAM_CMD_STAT 0x213*2 | ||
35 | #define IBM_MP2_BLOCK_SIZE 0x23b*2 | ||
36 | #define IBM_MP2_SRC_ADDR 0x23c*2 | ||
37 | /* Onscreen Display */ | ||
38 | #define IBM_MP2_OSD_ADDR 0x214*2 | ||
39 | #define IBM_MP2_OSD_DATA 0x215*2 | ||
40 | #define IBM_MP2_OSD_MODE 0x217*2 | ||
41 | #define IBM_MP2_OSD_LINK_ADDR 0x229*2 | ||
42 | #define IBM_MP2_OSD_SIZE 0x22a*2 | ||
43 | /* Interrupt Control */ | ||
44 | #define IBM_MP2_HOST_INT 0x218*2 | ||
45 | #define IBM_MP2_MASK0 0x219*2 | ||
46 | #define IBM_MP2_HOST_INT1 0x23e*2 | ||
47 | #define IBM_MP2_MASK1 0x23f*2 | ||
48 | /* Audio Control */ | ||
49 | #define IBM_MP2_AUD_IADDR 0x21a*2 | ||
50 | #define IBM_MP2_AUD_IDATA 0x21b*2 | ||
51 | #define IBM_MP2_AUD_FIFO 0x21c*2 | ||
52 | #define IBM_MP2_AUD_FIFOW 0x101*2 | ||
53 | #define IBM_MP2_AUD_CTL 0x21d*2 | ||
54 | #define IBM_MP2_BEEP_CTL 0x21e*2 | ||
55 | #define IBM_MP2_FRNT_ATTEN 0x22d*2 | ||
56 | /* Display Control */ | ||
57 | #define IBM_MP2_DISP_MODE 0x220*2 | ||
58 | #define IBM_MP2_DISP_DLY 0x221*2 | ||
59 | #define IBM_MP2_VBI_CTL 0x222*2 | ||
60 | #define IBM_MP2_DISP_LBOR 0x223*2 | ||
61 | #define IBM_MP2_DISP_TBOR 0x224*2 | ||
62 | /* Polarity Control */ | ||
63 | #define IBM_MP2_INFC_CTL 0x22c*2 | ||
64 | |||
65 | /* control commands */ | ||
66 | #define IBM_MP2_PLAY 0 | ||
67 | #define IBM_MP2_PAUSE 1 | ||
68 | #define IBM_MP2_SINGLE_FRAME 2 | ||
69 | #define IBM_MP2_FAST_FORWARD 3 | ||
70 | #define IBM_MP2_SLOW_MOTION 4 | ||
71 | #define IBM_MP2_IMED_NORM_PLAY 5 | ||
72 | #define IBM_MP2_RESET_WINDOW 6 | ||
73 | #define IBM_MP2_FREEZE_FRAME 7 | ||
74 | #define IBM_MP2_RESET_VID_RATE 8 | ||
75 | #define IBM_MP2_CONFIG_DECODER 9 | ||
76 | #define IBM_MP2_CHANNEL_SWITCH 10 | ||
77 | #define IBM_MP2_RESET_AUD_RATE 11 | ||
78 | #define IBM_MP2_PRE_OP_CHN_SW 12 | ||
79 | #define IBM_MP2_SET_STILL_MODE 14 | ||
80 | |||
81 | /* Define Xilinx FPGA Internal Registers */ | ||
82 | |||
83 | /* general control register 0 */ | ||
84 | #define XILINX_CTL0 0x600 | ||
85 | /* genlock delay resister 1 */ | ||
86 | #define XILINX_GLDELAY 0x602 | ||
87 | /* send 16 bits to CS3310 port */ | ||
88 | #define XILINX_CS3310 0x604 | ||
89 | /* send 16 bits to CS3310 and complete */ | ||
90 | #define XILINX_CS3310_CMPLT 0x60c | ||
91 | /* pulse width modulator control */ | ||
92 | #define XILINX_PWM 0x606 | ||
93 | |||
94 | #endif | ||
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index f7d57b3f2842..32a591062d0b 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
@@ -1830,18 +1830,6 @@ static long ivtv_default(struct file *file, void *fh, bool valid_prio, | |||
1830 | return 0; | 1830 | return 0; |
1831 | } | 1831 | } |
1832 | 1832 | ||
1833 | long ivtv_v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | ||
1834 | { | ||
1835 | struct video_device *vfd = video_devdata(filp); | ||
1836 | long ret; | ||
1837 | |||
1838 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) | ||
1839 | vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; | ||
1840 | ret = video_ioctl2(filp, cmd, arg); | ||
1841 | vfd->debug = 0; | ||
1842 | return ret; | ||
1843 | } | ||
1844 | |||
1845 | static const struct v4l2_ioctl_ops ivtv_ioctl_ops = { | 1833 | static const struct v4l2_ioctl_ops ivtv_ioctl_ops = { |
1846 | .vidioc_querycap = ivtv_querycap, | 1834 | .vidioc_querycap = ivtv_querycap, |
1847 | .vidioc_s_audio = ivtv_s_audio, | 1835 | .vidioc_s_audio = ivtv_s_audio, |
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.h b/drivers/media/video/ivtv/ivtv-ioctl.h index 89185caeafae..7c553d16579b 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.h +++ b/drivers/media/video/ivtv/ivtv-ioctl.h | |||
@@ -31,6 +31,5 @@ void ivtv_s_std_enc(struct ivtv *itv, v4l2_std_id *std); | |||
31 | void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id *std); | 31 | void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id *std); |
32 | int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); | 32 | int ivtv_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf); |
33 | int ivtv_s_input(struct file *file, void *fh, unsigned int inp); | 33 | int ivtv_s_input(struct file *file, void *fh, unsigned int inp); |
34 | long ivtv_v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); | ||
35 | 34 | ||
36 | #endif | 35 | #endif |
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index 6738592aa35d..87990c5f0910 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
@@ -50,7 +50,7 @@ static const struct v4l2_file_operations ivtv_v4l2_enc_fops = { | |||
50 | .read = ivtv_v4l2_read, | 50 | .read = ivtv_v4l2_read, |
51 | .write = ivtv_v4l2_write, | 51 | .write = ivtv_v4l2_write, |
52 | .open = ivtv_v4l2_open, | 52 | .open = ivtv_v4l2_open, |
53 | .unlocked_ioctl = ivtv_v4l2_ioctl, | 53 | .unlocked_ioctl = video_ioctl2, |
54 | .release = ivtv_v4l2_close, | 54 | .release = ivtv_v4l2_close, |
55 | .poll = ivtv_v4l2_enc_poll, | 55 | .poll = ivtv_v4l2_enc_poll, |
56 | }; | 56 | }; |
@@ -60,7 +60,7 @@ static const struct v4l2_file_operations ivtv_v4l2_dec_fops = { | |||
60 | .read = ivtv_v4l2_read, | 60 | .read = ivtv_v4l2_read, |
61 | .write = ivtv_v4l2_write, | 61 | .write = ivtv_v4l2_write, |
62 | .open = ivtv_v4l2_open, | 62 | .open = ivtv_v4l2_open, |
63 | .unlocked_ioctl = ivtv_v4l2_ioctl, | 63 | .unlocked_ioctl = video_ioctl2, |
64 | .release = ivtv_v4l2_close, | 64 | .release = ivtv_v4l2_close, |
65 | .poll = ivtv_v4l2_dec_poll, | 65 | .poll = ivtv_v4l2_dec_poll, |
66 | }; | 66 | }; |
diff --git a/drivers/media/video/m5mols/Kconfig b/drivers/media/video/m5mols/Kconfig index 302dc3d70193..dc8c2505907e 100644 --- a/drivers/media/video/m5mols/Kconfig +++ b/drivers/media/video/m5mols/Kconfig | |||
@@ -1,5 +1,6 @@ | |||
1 | config VIDEO_M5MOLS | 1 | config VIDEO_M5MOLS |
2 | tristate "Fujitsu M-5MOLS 8MP sensor support" | 2 | tristate "Fujitsu M-5MOLS 8MP sensor support" |
3 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API | 3 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API |
4 | depends on MEDIA_CAMERA_SUPPORT | ||
4 | ---help--- | 5 | ---help--- |
5 | This driver supports Fujitsu M-5MOLS camera sensor with ISP | 6 | This driver supports Fujitsu M-5MOLS camera sensor with ISP |
diff --git a/drivers/media/video/mem2mem_testdev.c b/drivers/media/video/mem2mem_testdev.c index 3945556f5733..f08cf38a496d 100644 --- a/drivers/media/video/mem2mem_testdev.c +++ b/drivers/media/video/mem2mem_testdev.c | |||
@@ -60,6 +60,10 @@ MODULE_VERSION("0.1.1"); | |||
60 | #define MEM2MEM_COLOR_STEP (0xff >> 4) | 60 | #define MEM2MEM_COLOR_STEP (0xff >> 4) |
61 | #define MEM2MEM_NUM_TILES 8 | 61 | #define MEM2MEM_NUM_TILES 8 |
62 | 62 | ||
63 | /* Flags that indicate processing mode */ | ||
64 | #define MEM2MEM_HFLIP (1 << 0) | ||
65 | #define MEM2MEM_VFLIP (1 << 1) | ||
66 | |||
63 | #define dprintk(dev, fmt, arg...) \ | 67 | #define dprintk(dev, fmt, arg...) \ |
64 | v4l2_dbg(1, 1, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg) | 68 | v4l2_dbg(1, 1, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg) |
65 | 69 | ||
@@ -115,6 +119,24 @@ enum { | |||
115 | 119 | ||
116 | static struct v4l2_queryctrl m2mtest_ctrls[] = { | 120 | static struct v4l2_queryctrl m2mtest_ctrls[] = { |
117 | { | 121 | { |
122 | .id = V4L2_CID_HFLIP, | ||
123 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
124 | .name = "Mirror", | ||
125 | .minimum = 0, | ||
126 | .maximum = 1, | ||
127 | .step = 1, | ||
128 | .default_value = 0, | ||
129 | .flags = 0, | ||
130 | }, { | ||
131 | .id = V4L2_CID_VFLIP, | ||
132 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
133 | .name = "Vertical Mirror", | ||
134 | .minimum = 0, | ||
135 | .maximum = 1, | ||
136 | .step = 1, | ||
137 | .default_value = 0, | ||
138 | .flags = 0, | ||
139 | }, { | ||
118 | .id = V4L2_CID_TRANS_TIME_MSEC, | 140 | .id = V4L2_CID_TRANS_TIME_MSEC, |
119 | .type = V4L2_CTRL_TYPE_INTEGER, | 141 | .type = V4L2_CTRL_TYPE_INTEGER, |
120 | .name = "Transaction time (msec)", | 142 | .name = "Transaction time (msec)", |
@@ -181,6 +203,9 @@ struct m2mtest_ctx { | |||
181 | /* Abort requested by m2m */ | 203 | /* Abort requested by m2m */ |
182 | int aborting; | 204 | int aborting; |
183 | 205 | ||
206 | /* Processing mode */ | ||
207 | int mode; | ||
208 | |||
184 | struct v4l2_m2m_ctx *m2m_ctx; | 209 | struct v4l2_m2m_ctx *m2m_ctx; |
185 | 210 | ||
186 | /* Source and destination queue data */ | 211 | /* Source and destination queue data */ |
@@ -249,19 +274,84 @@ static int device_process(struct m2mtest_ctx *ctx, | |||
249 | bytes_left = bytesperline - tile_w * MEM2MEM_NUM_TILES; | 274 | bytes_left = bytesperline - tile_w * MEM2MEM_NUM_TILES; |
250 | w = 0; | 275 | w = 0; |
251 | 276 | ||
252 | for (y = 0; y < height; ++y) { | 277 | switch (ctx->mode) { |
253 | for (t = 0; t < MEM2MEM_NUM_TILES; ++t) { | 278 | case MEM2MEM_HFLIP | MEM2MEM_VFLIP: |
254 | if (w & 0x1) { | 279 | p_out += bytesperline * height - bytes_left; |
255 | for (x = 0; x < tile_w; ++x) | 280 | for (y = 0; y < height; ++y) { |
256 | *p_out++ = *p_in++ + MEM2MEM_COLOR_STEP; | 281 | for (t = 0; t < MEM2MEM_NUM_TILES; ++t) { |
257 | } else { | 282 | if (w & 0x1) { |
258 | for (x = 0; x < tile_w; ++x) | 283 | for (x = 0; x < tile_w; ++x) |
259 | *p_out++ = *p_in++ - MEM2MEM_COLOR_STEP; | 284 | *--p_out = *p_in++ + |
285 | MEM2MEM_COLOR_STEP; | ||
286 | } else { | ||
287 | for (x = 0; x < tile_w; ++x) | ||
288 | *--p_out = *p_in++ - | ||
289 | MEM2MEM_COLOR_STEP; | ||
290 | } | ||
291 | ++w; | ||
260 | } | 292 | } |
261 | ++w; | 293 | p_in += bytes_left; |
294 | p_out -= bytes_left; | ||
295 | } | ||
296 | break; | ||
297 | |||
298 | case MEM2MEM_HFLIP: | ||
299 | for (y = 0; y < height; ++y) { | ||
300 | p_out += MEM2MEM_NUM_TILES * tile_w; | ||
301 | for (t = 0; t < MEM2MEM_NUM_TILES; ++t) { | ||
302 | if (w & 0x01) { | ||
303 | for (x = 0; x < tile_w; ++x) | ||
304 | *--p_out = *p_in++ + | ||
305 | MEM2MEM_COLOR_STEP; | ||
306 | } else { | ||
307 | for (x = 0; x < tile_w; ++x) | ||
308 | *--p_out = *p_in++ - | ||
309 | MEM2MEM_COLOR_STEP; | ||
310 | } | ||
311 | ++w; | ||
312 | } | ||
313 | p_in += bytes_left; | ||
314 | p_out += bytesperline; | ||
315 | } | ||
316 | break; | ||
317 | |||
318 | case MEM2MEM_VFLIP: | ||
319 | p_out += bytesperline * (height - 1); | ||
320 | for (y = 0; y < height; ++y) { | ||
321 | for (t = 0; t < MEM2MEM_NUM_TILES; ++t) { | ||
322 | if (w & 0x1) { | ||
323 | for (x = 0; x < tile_w; ++x) | ||
324 | *p_out++ = *p_in++ + | ||
325 | MEM2MEM_COLOR_STEP; | ||
326 | } else { | ||
327 | for (x = 0; x < tile_w; ++x) | ||
328 | *p_out++ = *p_in++ - | ||
329 | MEM2MEM_COLOR_STEP; | ||
330 | } | ||
331 | ++w; | ||
332 | } | ||
333 | p_in += bytes_left; | ||
334 | p_out += bytes_left - 2 * bytesperline; | ||
335 | } | ||
336 | break; | ||
337 | |||
338 | default: | ||
339 | for (y = 0; y < height; ++y) { | ||
340 | for (t = 0; t < MEM2MEM_NUM_TILES; ++t) { | ||
341 | if (w & 0x1) { | ||
342 | for (x = 0; x < tile_w; ++x) | ||
343 | *p_out++ = *p_in++ + | ||
344 | MEM2MEM_COLOR_STEP; | ||
345 | } else { | ||
346 | for (x = 0; x < tile_w; ++x) | ||
347 | *p_out++ = *p_in++ - | ||
348 | MEM2MEM_COLOR_STEP; | ||
349 | } | ||
350 | ++w; | ||
351 | } | ||
352 | p_in += bytes_left; | ||
353 | p_out += bytes_left; | ||
262 | } | 354 | } |
263 | p_in += bytes_left; | ||
264 | p_out += bytes_left; | ||
265 | } | 355 | } |
266 | 356 | ||
267 | return 0; | 357 | return 0; |
@@ -648,6 +738,14 @@ static int vidioc_g_ctrl(struct file *file, void *priv, | |||
648 | struct m2mtest_ctx *ctx = priv; | 738 | struct m2mtest_ctx *ctx = priv; |
649 | 739 | ||
650 | switch (ctrl->id) { | 740 | switch (ctrl->id) { |
741 | case V4L2_CID_HFLIP: | ||
742 | ctrl->value = (ctx->mode & MEM2MEM_HFLIP) ? 1 : 0; | ||
743 | break; | ||
744 | |||
745 | case V4L2_CID_VFLIP: | ||
746 | ctrl->value = (ctx->mode & MEM2MEM_VFLIP) ? 1 : 0; | ||
747 | break; | ||
748 | |||
651 | case V4L2_CID_TRANS_TIME_MSEC: | 749 | case V4L2_CID_TRANS_TIME_MSEC: |
652 | ctrl->value = ctx->transtime; | 750 | ctrl->value = ctx->transtime; |
653 | break; | 751 | break; |
@@ -691,6 +789,20 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
691 | return ret; | 789 | return ret; |
692 | 790 | ||
693 | switch (ctrl->id) { | 791 | switch (ctrl->id) { |
792 | case V4L2_CID_HFLIP: | ||
793 | if (ctrl->value) | ||
794 | ctx->mode |= MEM2MEM_HFLIP; | ||
795 | else | ||
796 | ctx->mode &= ~MEM2MEM_HFLIP; | ||
797 | break; | ||
798 | |||
799 | case V4L2_CID_VFLIP: | ||
800 | if (ctrl->value) | ||
801 | ctx->mode |= MEM2MEM_VFLIP; | ||
802 | else | ||
803 | ctx->mode &= ~MEM2MEM_VFLIP; | ||
804 | break; | ||
805 | |||
694 | case V4L2_CID_TRANS_TIME_MSEC: | 806 | case V4L2_CID_TRANS_TIME_MSEC: |
695 | ctx->transtime = ctrl->value; | 807 | ctx->transtime = ctrl->value; |
696 | break; | 808 | break; |
@@ -861,6 +973,7 @@ static int m2mtest_open(struct file *file) | |||
861 | ctx->translen = MEM2MEM_DEF_TRANSLEN; | 973 | ctx->translen = MEM2MEM_DEF_TRANSLEN; |
862 | ctx->transtime = MEM2MEM_DEF_TRANSTIME; | 974 | ctx->transtime = MEM2MEM_DEF_TRANSTIME; |
863 | ctx->num_processed = 0; | 975 | ctx->num_processed = 0; |
976 | ctx->mode = 0; | ||
864 | 977 | ||
865 | ctx->q_data[V4L2_M2M_SRC].fmt = &formats[0]; | 978 | ctx->q_data[V4L2_M2M_SRC].fmt = &formats[0]; |
866 | ctx->q_data[V4L2_M2M_DST].fmt = &formats[0]; | 979 | ctx->q_data[V4L2_M2M_DST].fmt = &formats[0]; |
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c index 7e648183f157..00583f5fd26b 100644 --- a/drivers/media/video/mt9m001.c +++ b/drivers/media/video/mt9m001.c | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | /* | 23 | /* |
24 | * mt9m001 i2c address 0x5d | 24 | * mt9m001 i2c address 0x5d |
25 | * The platform has to define ctruct i2c_board_info objects and link to them | 25 | * The platform has to define struct i2c_board_info objects and link to them |
26 | * from struct soc_camera_link | 26 | * from struct soc_camera_link |
27 | */ | 27 | */ |
28 | 28 | ||
diff --git a/drivers/media/video/mt9m032.c b/drivers/media/video/mt9m032.c index 3c1e626139b7..445359c96113 100644 --- a/drivers/media/video/mt9m032.c +++ b/drivers/media/video/mt9m032.c | |||
@@ -688,11 +688,17 @@ static const struct v4l2_subdev_ops mt9m032_ops = { | |||
688 | static int mt9m032_probe(struct i2c_client *client, | 688 | static int mt9m032_probe(struct i2c_client *client, |
689 | const struct i2c_device_id *devid) | 689 | const struct i2c_device_id *devid) |
690 | { | 690 | { |
691 | struct mt9m032_platform_data *pdata = client->dev.platform_data; | ||
691 | struct i2c_adapter *adapter = client->adapter; | 692 | struct i2c_adapter *adapter = client->adapter; |
692 | struct mt9m032 *sensor; | 693 | struct mt9m032 *sensor; |
693 | int chip_version; | 694 | int chip_version; |
694 | int ret; | 695 | int ret; |
695 | 696 | ||
697 | if (pdata == NULL) { | ||
698 | dev_err(&client->dev, "No platform data\n"); | ||
699 | return -EINVAL; | ||
700 | } | ||
701 | |||
696 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) { | 702 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) { |
697 | dev_warn(&client->dev, | 703 | dev_warn(&client->dev, |
698 | "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n"); | 704 | "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n"); |
@@ -708,7 +714,7 @@ static int mt9m032_probe(struct i2c_client *client, | |||
708 | 714 | ||
709 | mutex_init(&sensor->lock); | 715 | mutex_init(&sensor->lock); |
710 | 716 | ||
711 | sensor->pdata = client->dev.platform_data; | 717 | sensor->pdata = pdata; |
712 | 718 | ||
713 | v4l2_i2c_subdev_init(&sensor->subdev, client, &mt9m032_ops); | 719 | v4l2_i2c_subdev_init(&sensor->subdev, client, &mt9m032_ops); |
714 | sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; | 720 | sensor->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; |
@@ -738,7 +744,7 @@ static int mt9m032_probe(struct i2c_client *client, | |||
738 | sensor->format.field = V4L2_FIELD_NONE; | 744 | sensor->format.field = V4L2_FIELD_NONE; |
739 | sensor->format.colorspace = V4L2_COLORSPACE_SRGB; | 745 | sensor->format.colorspace = V4L2_COLORSPACE_SRGB; |
740 | 746 | ||
741 | v4l2_ctrl_handler_init(&sensor->ctrls, 4); | 747 | v4l2_ctrl_handler_init(&sensor->ctrls, 5); |
742 | 748 | ||
743 | v4l2_ctrl_new_std(&sensor->ctrls, &mt9m032_ctrl_ops, | 749 | v4l2_ctrl_new_std(&sensor->ctrls, &mt9m032_ctrl_ops, |
744 | V4L2_CID_GAIN, 0, 127, 1, 64); | 750 | V4L2_CID_GAIN, 0, 127, 1, 64); |
@@ -754,6 +760,9 @@ static int mt9m032_probe(struct i2c_client *client, | |||
754 | V4L2_CID_EXPOSURE, MT9M032_SHUTTER_WIDTH_MIN, | 760 | V4L2_CID_EXPOSURE, MT9M032_SHUTTER_WIDTH_MIN, |
755 | MT9M032_SHUTTER_WIDTH_MAX, 1, | 761 | MT9M032_SHUTTER_WIDTH_MAX, 1, |
756 | MT9M032_SHUTTER_WIDTH_DEF); | 762 | MT9M032_SHUTTER_WIDTH_DEF); |
763 | v4l2_ctrl_new_std(&sensor->ctrls, &mt9m032_ctrl_ops, | ||
764 | V4L2_CID_PIXEL_RATE, pdata->pix_clock, | ||
765 | pdata->pix_clock, 1, pdata->pix_clock); | ||
757 | 766 | ||
758 | if (sensor->ctrls.error) { | 767 | if (sensor->ctrls.error) { |
759 | ret = sensor->ctrls.error; | 768 | ret = sensor->ctrls.error; |
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c index b0c529964329..863d722dda06 100644 --- a/drivers/media/video/mt9m111.c +++ b/drivers/media/video/mt9m111.c | |||
@@ -214,7 +214,6 @@ struct mt9m111 { | |||
214 | int power_count; | 214 | int power_count; |
215 | const struct mt9m111_datafmt *fmt; | 215 | const struct mt9m111_datafmt *fmt; |
216 | int lastpage; /* PageMap cache value */ | 216 | int lastpage; /* PageMap cache value */ |
217 | unsigned char datawidth; | ||
218 | }; | 217 | }; |
219 | 218 | ||
220 | /* Find a data format by a pixel code */ | 219 | /* Find a data format by a pixel code */ |
diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c index 8f061d9ac443..3be537ef22d2 100644 --- a/drivers/media/video/mt9p031.c +++ b/drivers/media/video/mt9p031.c | |||
@@ -950,7 +950,7 @@ static int mt9p031_probe(struct i2c_client *client, | |||
950 | mt9p031->model = did->driver_data; | 950 | mt9p031->model = did->driver_data; |
951 | mt9p031->reset = -1; | 951 | mt9p031->reset = -1; |
952 | 952 | ||
953 | v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4); | 953 | v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 5); |
954 | 954 | ||
955 | v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops, | 955 | v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops, |
956 | V4L2_CID_EXPOSURE, MT9P031_SHUTTER_WIDTH_MIN, | 956 | V4L2_CID_EXPOSURE, MT9P031_SHUTTER_WIDTH_MIN, |
@@ -963,6 +963,9 @@ static int mt9p031_probe(struct i2c_client *client, | |||
963 | V4L2_CID_HFLIP, 0, 1, 1, 0); | 963 | V4L2_CID_HFLIP, 0, 1, 1, 0); |
964 | v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops, | 964 | v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops, |
965 | V4L2_CID_VFLIP, 0, 1, 1, 0); | 965 | V4L2_CID_VFLIP, 0, 1, 1, 0); |
966 | v4l2_ctrl_new_std(&mt9p031->ctrls, &mt9p031_ctrl_ops, | ||
967 | V4L2_CID_PIXEL_RATE, pdata->target_freq, | ||
968 | pdata->target_freq, 1, pdata->target_freq); | ||
966 | 969 | ||
967 | for (i = 0; i < ARRAY_SIZE(mt9p031_ctrls); ++i) | 970 | for (i = 0; i < ARRAY_SIZE(mt9p031_ctrls); ++i) |
968 | v4l2_ctrl_new_custom(&mt9p031->ctrls, &mt9p031_ctrls[i], NULL); | 971 | v4l2_ctrl_new_custom(&mt9p031->ctrls, &mt9p031_ctrls[i], NULL); |
diff --git a/drivers/media/video/mt9t001.c b/drivers/media/video/mt9t001.c index 49ca3cbfc6f1..6d343adf891d 100644 --- a/drivers/media/video/mt9t001.c +++ b/drivers/media/video/mt9t001.c | |||
@@ -691,7 +691,7 @@ static int mt9t001_video_probe(struct i2c_client *client) | |||
691 | return ret; | 691 | return ret; |
692 | 692 | ||
693 | /* Configure the pixel clock polarity */ | 693 | /* Configure the pixel clock polarity */ |
694 | if (pdata && pdata->clk_pol) { | 694 | if (pdata->clk_pol) { |
695 | ret = mt9t001_write(client, MT9T001_PIXEL_CLOCK, | 695 | ret = mt9t001_write(client, MT9T001_PIXEL_CLOCK, |
696 | MT9T001_PIXEL_CLOCK_INVERT); | 696 | MT9T001_PIXEL_CLOCK_INVERT); |
697 | if (ret < 0) | 697 | if (ret < 0) |
@@ -715,10 +715,16 @@ static int mt9t001_video_probe(struct i2c_client *client) | |||
715 | static int mt9t001_probe(struct i2c_client *client, | 715 | static int mt9t001_probe(struct i2c_client *client, |
716 | const struct i2c_device_id *did) | 716 | const struct i2c_device_id *did) |
717 | { | 717 | { |
718 | struct mt9t001_platform_data *pdata = client->dev.platform_data; | ||
718 | struct mt9t001 *mt9t001; | 719 | struct mt9t001 *mt9t001; |
719 | unsigned int i; | 720 | unsigned int i; |
720 | int ret; | 721 | int ret; |
721 | 722 | ||
723 | if (pdata == NULL) { | ||
724 | dev_err(&client->dev, "No platform data\n"); | ||
725 | return -EINVAL; | ||
726 | } | ||
727 | |||
722 | if (!i2c_check_functionality(client->adapter, | 728 | if (!i2c_check_functionality(client->adapter, |
723 | I2C_FUNC_SMBUS_WORD_DATA)) { | 729 | I2C_FUNC_SMBUS_WORD_DATA)) { |
724 | dev_warn(&client->adapter->dev, | 730 | dev_warn(&client->adapter->dev, |
@@ -735,7 +741,7 @@ static int mt9t001_probe(struct i2c_client *client, | |||
735 | return -ENOMEM; | 741 | return -ENOMEM; |
736 | 742 | ||
737 | v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) + | 743 | v4l2_ctrl_handler_init(&mt9t001->ctrls, ARRAY_SIZE(mt9t001_ctrls) + |
738 | ARRAY_SIZE(mt9t001_gains) + 2); | 744 | ARRAY_SIZE(mt9t001_gains) + 3); |
739 | 745 | ||
740 | v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, | 746 | v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, |
741 | V4L2_CID_EXPOSURE, MT9T001_SHUTTER_WIDTH_MIN, | 747 | V4L2_CID_EXPOSURE, MT9T001_SHUTTER_WIDTH_MIN, |
@@ -743,6 +749,9 @@ static int mt9t001_probe(struct i2c_client *client, | |||
743 | MT9T001_SHUTTER_WIDTH_DEF); | 749 | MT9T001_SHUTTER_WIDTH_DEF); |
744 | v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, | 750 | v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, |
745 | V4L2_CID_BLACK_LEVEL, 1, 1, 1, 1); | 751 | V4L2_CID_BLACK_LEVEL, 1, 1, 1, 1); |
752 | v4l2_ctrl_new_std(&mt9t001->ctrls, &mt9t001_ctrl_ops, | ||
753 | V4L2_CID_PIXEL_RATE, pdata->ext_clk, pdata->ext_clk, | ||
754 | 1, pdata->ext_clk); | ||
746 | 755 | ||
747 | for (i = 0; i < ARRAY_SIZE(mt9t001_ctrls); ++i) | 756 | for (i = 0; i < ARRAY_SIZE(mt9t001_ctrls); ++i) |
748 | v4l2_ctrl_new_custom(&mt9t001->ctrls, &mt9t001_ctrls[i], NULL); | 757 | v4l2_ctrl_new_custom(&mt9t001->ctrls, &mt9t001_ctrls[i], NULL); |
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c index bf63417adb8f..72479247522a 100644 --- a/drivers/media/video/mt9v022.c +++ b/drivers/media/video/mt9v022.c | |||
@@ -23,7 +23,7 @@ | |||
23 | 23 | ||
24 | /* | 24 | /* |
25 | * mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c | 25 | * mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c |
26 | * The platform has to define ctruct i2c_board_info objects and link to them | 26 | * The platform has to define struct i2c_board_info objects and link to them |
27 | * from struct soc_camera_link | 27 | * from struct soc_camera_link |
28 | */ | 28 | */ |
29 | 29 | ||
diff --git a/drivers/media/video/omap3isp/ispccdc.c b/drivers/media/video/omap3isp/ispccdc.c index 7e32331b60fb..f1220d3d4970 100644 --- a/drivers/media/video/omap3isp/ispccdc.c +++ b/drivers/media/video/omap3isp/ispccdc.c | |||
@@ -2014,7 +2014,7 @@ static int ccdc_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
2014 | return -EINVAL; | 2014 | return -EINVAL; |
2015 | 2015 | ||
2016 | switch (sel->target) { | 2016 | switch (sel->target) { |
2017 | case V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS: | 2017 | case V4L2_SEL_TGT_CROP_BOUNDS: |
2018 | sel->r.left = 0; | 2018 | sel->r.left = 0; |
2019 | sel->r.top = 0; | 2019 | sel->r.top = 0; |
2020 | sel->r.width = INT_MAX; | 2020 | sel->r.width = INT_MAX; |
@@ -2024,7 +2024,7 @@ static int ccdc_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
2024 | ccdc_try_crop(ccdc, format, &sel->r); | 2024 | ccdc_try_crop(ccdc, format, &sel->r); |
2025 | break; | 2025 | break; |
2026 | 2026 | ||
2027 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 2027 | case V4L2_SEL_TGT_CROP: |
2028 | sel->r = *__ccdc_get_crop(ccdc, fh, sel->which); | 2028 | sel->r = *__ccdc_get_crop(ccdc, fh, sel->which); |
2029 | break; | 2029 | break; |
2030 | 2030 | ||
@@ -2052,7 +2052,7 @@ static int ccdc_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
2052 | struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); | 2052 | struct isp_ccdc_device *ccdc = v4l2_get_subdevdata(sd); |
2053 | struct v4l2_mbus_framefmt *format; | 2053 | struct v4l2_mbus_framefmt *format; |
2054 | 2054 | ||
2055 | if (sel->target != V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL || | 2055 | if (sel->target != V4L2_SEL_TGT_CROP || |
2056 | sel->pad != CCDC_PAD_SOURCE_OF) | 2056 | sel->pad != CCDC_PAD_SOURCE_OF) |
2057 | return -EINVAL; | 2057 | return -EINVAL; |
2058 | 2058 | ||
@@ -2064,7 +2064,7 @@ static int ccdc_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, | |||
2064 | * pad. If the KEEP_CONFIG flag is set, just return the current crop | 2064 | * pad. If the KEEP_CONFIG flag is set, just return the current crop |
2065 | * rectangle. | 2065 | * rectangle. |
2066 | */ | 2066 | */ |
2067 | if (sel->flags & V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG) { | 2067 | if (sel->flags & V4L2_SEL_FLAG_KEEP_CONFIG) { |
2068 | sel->r = *__ccdc_get_crop(ccdc, fh, sel->which); | 2068 | sel->r = *__ccdc_get_crop(ccdc, fh, sel->which); |
2069 | return 0; | 2069 | return 0; |
2070 | } | 2070 | } |
diff --git a/drivers/media/video/omap3isp/isppreview.c b/drivers/media/video/omap3isp/isppreview.c index dd91da26f1b0..53f5a703e31a 100644 --- a/drivers/media/video/omap3isp/isppreview.c +++ b/drivers/media/video/omap3isp/isppreview.c | |||
@@ -1949,7 +1949,7 @@ static int preview_get_selection(struct v4l2_subdev *sd, | |||
1949 | return -EINVAL; | 1949 | return -EINVAL; |
1950 | 1950 | ||
1951 | switch (sel->target) { | 1951 | switch (sel->target) { |
1952 | case V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS: | 1952 | case V4L2_SEL_TGT_CROP_BOUNDS: |
1953 | sel->r.left = 0; | 1953 | sel->r.left = 0; |
1954 | sel->r.top = 0; | 1954 | sel->r.top = 0; |
1955 | sel->r.width = INT_MAX; | 1955 | sel->r.width = INT_MAX; |
@@ -1960,7 +1960,7 @@ static int preview_get_selection(struct v4l2_subdev *sd, | |||
1960 | preview_try_crop(prev, format, &sel->r); | 1960 | preview_try_crop(prev, format, &sel->r); |
1961 | break; | 1961 | break; |
1962 | 1962 | ||
1963 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 1963 | case V4L2_SEL_TGT_CROP: |
1964 | sel->r = *__preview_get_crop(prev, fh, sel->which); | 1964 | sel->r = *__preview_get_crop(prev, fh, sel->which); |
1965 | break; | 1965 | break; |
1966 | 1966 | ||
@@ -1988,7 +1988,7 @@ static int preview_set_selection(struct v4l2_subdev *sd, | |||
1988 | struct isp_prev_device *prev = v4l2_get_subdevdata(sd); | 1988 | struct isp_prev_device *prev = v4l2_get_subdevdata(sd); |
1989 | struct v4l2_mbus_framefmt *format; | 1989 | struct v4l2_mbus_framefmt *format; |
1990 | 1990 | ||
1991 | if (sel->target != V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL || | 1991 | if (sel->target != V4L2_SEL_TGT_CROP || |
1992 | sel->pad != PREV_PAD_SINK) | 1992 | sel->pad != PREV_PAD_SINK) |
1993 | return -EINVAL; | 1993 | return -EINVAL; |
1994 | 1994 | ||
@@ -2000,7 +2000,7 @@ static int preview_set_selection(struct v4l2_subdev *sd, | |||
2000 | * pad. If the KEEP_CONFIG flag is set, just return the current crop | 2000 | * pad. If the KEEP_CONFIG flag is set, just return the current crop |
2001 | * rectangle. | 2001 | * rectangle. |
2002 | */ | 2002 | */ |
2003 | if (sel->flags & V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG) { | 2003 | if (sel->flags & V4L2_SEL_FLAG_KEEP_CONFIG) { |
2004 | sel->r = *__preview_get_crop(prev, fh, sel->which); | 2004 | sel->r = *__preview_get_crop(prev, fh, sel->which); |
2005 | return 0; | 2005 | return 0; |
2006 | } | 2006 | } |
diff --git a/drivers/media/video/omap3isp/ispresizer.c b/drivers/media/video/omap3isp/ispresizer.c index 14041c9c8643..ae17d917f77b 100644 --- a/drivers/media/video/omap3isp/ispresizer.c +++ b/drivers/media/video/omap3isp/ispresizer.c | |||
@@ -1249,7 +1249,7 @@ static int resizer_get_selection(struct v4l2_subdev *sd, | |||
1249 | sel->which); | 1249 | sel->which); |
1250 | 1250 | ||
1251 | switch (sel->target) { | 1251 | switch (sel->target) { |
1252 | case V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS: | 1252 | case V4L2_SEL_TGT_CROP_BOUNDS: |
1253 | sel->r.left = 0; | 1253 | sel->r.left = 0; |
1254 | sel->r.top = 0; | 1254 | sel->r.top = 0; |
1255 | sel->r.width = INT_MAX; | 1255 | sel->r.width = INT_MAX; |
@@ -1259,7 +1259,7 @@ static int resizer_get_selection(struct v4l2_subdev *sd, | |||
1259 | resizer_calc_ratios(res, &sel->r, format_source, &ratio); | 1259 | resizer_calc_ratios(res, &sel->r, format_source, &ratio); |
1260 | break; | 1260 | break; |
1261 | 1261 | ||
1262 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 1262 | case V4L2_SEL_TGT_CROP: |
1263 | sel->r = *__resizer_get_crop(res, fh, sel->which); | 1263 | sel->r = *__resizer_get_crop(res, fh, sel->which); |
1264 | resizer_calc_ratios(res, &sel->r, format_source, &ratio); | 1264 | resizer_calc_ratios(res, &sel->r, format_source, &ratio); |
1265 | break; | 1265 | break; |
@@ -1293,7 +1293,7 @@ static int resizer_set_selection(struct v4l2_subdev *sd, | |||
1293 | struct v4l2_mbus_framefmt *format_sink, *format_source; | 1293 | struct v4l2_mbus_framefmt *format_sink, *format_source; |
1294 | struct resizer_ratio ratio; | 1294 | struct resizer_ratio ratio; |
1295 | 1295 | ||
1296 | if (sel->target != V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL || | 1296 | if (sel->target != V4L2_SEL_TGT_CROP || |
1297 | sel->pad != RESZ_PAD_SINK) | 1297 | sel->pad != RESZ_PAD_SINK) |
1298 | return -EINVAL; | 1298 | return -EINVAL; |
1299 | 1299 | ||
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig index f9b6001e1dd7..25e412ecad2c 100644 --- a/drivers/media/video/pvrusb2/Kconfig +++ b/drivers/media/video/pvrusb2/Kconfig | |||
@@ -1,7 +1,6 @@ | |||
1 | config VIDEO_PVRUSB2 | 1 | config VIDEO_PVRUSB2 |
2 | tristate "Hauppauge WinTV-PVR USB2 support" | 2 | tristate "Hauppauge WinTV-PVR USB2 support" |
3 | depends on VIDEO_V4L2 && I2C | 3 | depends on VIDEO_V4L2 && I2C |
4 | depends on VIDEO_MEDIA # Avoids pvrusb = Y / DVB = M | ||
5 | select VIDEO_TUNER | 4 | select VIDEO_TUNER |
6 | select VIDEO_TVEEPROM | 5 | select VIDEO_TVEEPROM |
7 | select VIDEO_CX2341X | 6 | select VIDEO_CX2341X |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index 7bddfaeeafc3..f344aed32a93 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c | |||
@@ -226,13 +226,11 @@ static int pvr2_enum_input(struct file *file, void *priv, struct v4l2_input *vi) | |||
226 | struct v4l2_input tmp; | 226 | struct v4l2_input tmp; |
227 | unsigned int cnt; | 227 | unsigned int cnt; |
228 | int val; | 228 | int val; |
229 | int ret; | ||
230 | 229 | ||
231 | cptr = pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_INPUT); | 230 | cptr = pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_INPUT); |
232 | 231 | ||
233 | memset(&tmp, 0, sizeof(tmp)); | 232 | memset(&tmp, 0, sizeof(tmp)); |
234 | tmp.index = vi->index; | 233 | tmp.index = vi->index; |
235 | ret = 0; | ||
236 | if (vi->index >= fh->input_cnt) | 234 | if (vi->index >= fh->input_cnt) |
237 | return -EINVAL; | 235 | return -EINVAL; |
238 | val = fh->input_map[vi->index]; | 236 | val = fh->input_map[vi->index]; |
@@ -556,9 +554,7 @@ static int pvr2_queryctrl(struct file *file, void *priv, | |||
556 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; | 554 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; |
557 | struct pvr2_ctrl *cptr; | 555 | struct pvr2_ctrl *cptr; |
558 | int val; | 556 | int val; |
559 | int ret; | ||
560 | 557 | ||
561 | ret = 0; | ||
562 | if (vc->id & V4L2_CTRL_FLAG_NEXT_CTRL) { | 558 | if (vc->id & V4L2_CTRL_FLAG_NEXT_CTRL) { |
563 | cptr = pvr2_hdw_get_ctrl_nextv4l( | 559 | cptr = pvr2_hdw_get_ctrl_nextv4l( |
564 | hdw, (vc->id & ~V4L2_CTRL_FLAG_NEXT_CTRL)); | 560 | hdw, (vc->id & ~V4L2_CTRL_FLAG_NEXT_CTRL)); |
@@ -705,11 +701,9 @@ static int pvr2_try_ext_ctrls(struct file *file, void *priv, | |||
705 | struct v4l2_ext_control *ctrl; | 701 | struct v4l2_ext_control *ctrl; |
706 | struct pvr2_ctrl *pctl; | 702 | struct pvr2_ctrl *pctl; |
707 | unsigned int idx; | 703 | unsigned int idx; |
708 | int ret; | ||
709 | 704 | ||
710 | /* For the moment just validate that the requested control | 705 | /* For the moment just validate that the requested control |
711 | actually exists. */ | 706 | actually exists. */ |
712 | ret = 0; | ||
713 | for (idx = 0; idx < ctls->count; idx++) { | 707 | for (idx = 0; idx < ctls->count; idx++) { |
714 | ctrl = ctls->controls + idx; | 708 | ctrl = ctls->controls + idx; |
715 | pctl = pvr2_hdw_get_ctrl_v4l(hdw, ctrl->id); | 709 | pctl = pvr2_hdw_get_ctrl_v4l(hdw, ctrl->id); |
@@ -770,12 +764,10 @@ static int pvr2_s_crop(struct file *file, void *priv, struct v4l2_crop *crop) | |||
770 | { | 764 | { |
771 | struct pvr2_v4l2_fh *fh = file->private_data; | 765 | struct pvr2_v4l2_fh *fh = file->private_data; |
772 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; | 766 | struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; |
773 | struct v4l2_cropcap cap; | ||
774 | int ret; | 767 | int ret; |
775 | 768 | ||
776 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 769 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
777 | return -EINVAL; | 770 | return -EINVAL; |
778 | cap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
779 | ret = pvr2_ctrl_set_value( | 771 | ret = pvr2_ctrl_set_value( |
780 | pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPL), | 772 | pvr2_hdw_get_ctrl_by_id(hdw, PVR2_CID_CROPL), |
781 | crop->c.left); | 773 | crop->c.left); |
@@ -965,7 +957,7 @@ static long pvr2_v4l2_ioctl(struct file *file, | |||
965 | long ret = -EINVAL; | 957 | long ret = -EINVAL; |
966 | 958 | ||
967 | if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) | 959 | if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) |
968 | v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw), cmd); | 960 | v4l_printk_ioctl(pvr2_hdw_get_driver_name(hdw), cmd); |
969 | 961 | ||
970 | if (!pvr2_hdw_dev_ok(hdw)) { | 962 | if (!pvr2_hdw_dev_ok(hdw)) { |
971 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 963 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
@@ -998,7 +990,7 @@ static long pvr2_v4l2_ioctl(struct file *file, | |||
998 | pvr2_trace(PVR2_TRACE_V4LIOCTL, | 990 | pvr2_trace(PVR2_TRACE_V4LIOCTL, |
999 | "pvr2_v4l2_do_ioctl failure, ret=%ld" | 991 | "pvr2_v4l2_do_ioctl failure, ret=%ld" |
1000 | " command was:", ret); | 992 | " command was:", ret); |
1001 | v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw), | 993 | v4l_printk_ioctl(pvr2_hdw_get_driver_name(hdw), |
1002 | cmd); | 994 | cmd); |
1003 | } | 995 | } |
1004 | } | 996 | } |
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index ec4e2ef54e65..de7c7ba99ef4 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
@@ -136,19 +136,13 @@ static int leds[2] = { 100, 0 }; | |||
136 | 136 | ||
137 | /***/ | 137 | /***/ |
138 | 138 | ||
139 | static int pwc_video_close(struct file *file); | ||
140 | static ssize_t pwc_video_read(struct file *file, char __user *buf, | ||
141 | size_t count, loff_t *ppos); | ||
142 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait); | ||
143 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma); | ||
144 | |||
145 | static const struct v4l2_file_operations pwc_fops = { | 139 | static const struct v4l2_file_operations pwc_fops = { |
146 | .owner = THIS_MODULE, | 140 | .owner = THIS_MODULE, |
147 | .open = v4l2_fh_open, | 141 | .open = v4l2_fh_open, |
148 | .release = pwc_video_close, | 142 | .release = vb2_fop_release, |
149 | .read = pwc_video_read, | 143 | .read = vb2_fop_read, |
150 | .poll = pwc_video_poll, | 144 | .poll = vb2_fop_poll, |
151 | .mmap = pwc_video_mmap, | 145 | .mmap = vb2_fop_mmap, |
152 | .unlocked_ioctl = video_ioctl2, | 146 | .unlocked_ioctl = video_ioctl2, |
153 | }; | 147 | }; |
154 | static struct video_device pwc_template = { | 148 | static struct video_device pwc_template = { |
@@ -562,17 +556,6 @@ static const char *pwc_sensor_type_to_string(unsigned int sensor_type) | |||
562 | /***************************************************************************/ | 556 | /***************************************************************************/ |
563 | /* Video4Linux functions */ | 557 | /* Video4Linux functions */ |
564 | 558 | ||
565 | int pwc_test_n_set_capt_file(struct pwc_device *pdev, struct file *file) | ||
566 | { | ||
567 | if (pdev->capt_file != NULL && | ||
568 | pdev->capt_file != file) | ||
569 | return -EBUSY; | ||
570 | |||
571 | pdev->capt_file = file; | ||
572 | |||
573 | return 0; | ||
574 | } | ||
575 | |||
576 | static void pwc_video_release(struct v4l2_device *v) | 559 | static void pwc_video_release(struct v4l2_device *v) |
577 | { | 560 | { |
578 | struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); | 561 | struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); |
@@ -583,113 +566,6 @@ static void pwc_video_release(struct v4l2_device *v) | |||
583 | kfree(pdev); | 566 | kfree(pdev); |
584 | } | 567 | } |
585 | 568 | ||
586 | static int pwc_video_close(struct file *file) | ||
587 | { | ||
588 | struct pwc_device *pdev = video_drvdata(file); | ||
589 | |||
590 | /* | ||
591 | * If we're still streaming vb2_queue_release will call stream_stop | ||
592 | * so we must take both the v4l2_lock and the vb_queue_lock. | ||
593 | */ | ||
594 | if (mutex_lock_interruptible(&pdev->v4l2_lock)) | ||
595 | return -ERESTARTSYS; | ||
596 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) { | ||
597 | mutex_unlock(&pdev->v4l2_lock); | ||
598 | return -ERESTARTSYS; | ||
599 | } | ||
600 | |||
601 | if (pdev->capt_file == file) { | ||
602 | vb2_queue_release(&pdev->vb_queue); | ||
603 | pdev->capt_file = NULL; | ||
604 | } | ||
605 | |||
606 | mutex_unlock(&pdev->vb_queue_lock); | ||
607 | mutex_unlock(&pdev->v4l2_lock); | ||
608 | |||
609 | return v4l2_fh_release(file); | ||
610 | } | ||
611 | |||
612 | static ssize_t pwc_video_read(struct file *file, char __user *buf, | ||
613 | size_t count, loff_t *ppos) | ||
614 | { | ||
615 | struct pwc_device *pdev = video_drvdata(file); | ||
616 | int lock_v4l2 = 0; | ||
617 | ssize_t ret; | ||
618 | |||
619 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
620 | return -ERESTARTSYS; | ||
621 | |||
622 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
623 | if (ret) | ||
624 | goto out; | ||
625 | |||
626 | /* stream_start will get called so we must take the v4l2_lock */ | ||
627 | if (pdev->vb_queue.fileio == NULL) | ||
628 | lock_v4l2 = 1; | ||
629 | |||
630 | /* Use try_lock, since we're taking the locks in the *wrong* order! */ | ||
631 | if (lock_v4l2 && !mutex_trylock(&pdev->v4l2_lock)) { | ||
632 | ret = -ERESTARTSYS; | ||
633 | goto out; | ||
634 | } | ||
635 | ret = vb2_read(&pdev->vb_queue, buf, count, ppos, | ||
636 | file->f_flags & O_NONBLOCK); | ||
637 | if (lock_v4l2) | ||
638 | mutex_unlock(&pdev->v4l2_lock); | ||
639 | out: | ||
640 | mutex_unlock(&pdev->vb_queue_lock); | ||
641 | return ret; | ||
642 | } | ||
643 | |||
644 | static unsigned int pwc_video_poll(struct file *file, poll_table *wait) | ||
645 | { | ||
646 | struct pwc_device *pdev = video_drvdata(file); | ||
647 | struct vb2_queue *q = &pdev->vb_queue; | ||
648 | unsigned long req_events = poll_requested_events(wait); | ||
649 | unsigned int ret = POLL_ERR; | ||
650 | int lock_v4l2 = 0; | ||
651 | |||
652 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
653 | return POLL_ERR; | ||
654 | |||
655 | /* Will this start fileio and thus call start_stream? */ | ||
656 | if ((req_events & (POLLIN | POLLRDNORM)) && | ||
657 | q->num_buffers == 0 && !q->streaming && q->fileio == NULL) { | ||
658 | if (pwc_test_n_set_capt_file(pdev, file)) | ||
659 | goto out; | ||
660 | lock_v4l2 = 1; | ||
661 | } | ||
662 | |||
663 | /* Use try_lock, since we're taking the locks in the *wrong* order! */ | ||
664 | if (lock_v4l2 && !mutex_trylock(&pdev->v4l2_lock)) | ||
665 | goto out; | ||
666 | ret = vb2_poll(&pdev->vb_queue, file, wait); | ||
667 | if (lock_v4l2) | ||
668 | mutex_unlock(&pdev->v4l2_lock); | ||
669 | |||
670 | out: | ||
671 | if (!pdev->udev) | ||
672 | ret |= POLLHUP; | ||
673 | mutex_unlock(&pdev->vb_queue_lock); | ||
674 | return ret; | ||
675 | } | ||
676 | |||
677 | static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma) | ||
678 | { | ||
679 | struct pwc_device *pdev = video_drvdata(file); | ||
680 | int ret; | ||
681 | |||
682 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
683 | return -ERESTARTSYS; | ||
684 | |||
685 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
686 | if (ret == 0) | ||
687 | ret = vb2_mmap(&pdev->vb_queue, vma); | ||
688 | |||
689 | mutex_unlock(&pdev->vb_queue_lock); | ||
690 | return ret; | ||
691 | } | ||
692 | |||
693 | /***************************************************************************/ | 569 | /***************************************************************************/ |
694 | /* Videobuf2 operations */ | 570 | /* Videobuf2 operations */ |
695 | 571 | ||
@@ -782,6 +658,8 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) | |||
782 | if (!pdev->udev) | 658 | if (!pdev->udev) |
783 | return -ENODEV; | 659 | return -ENODEV; |
784 | 660 | ||
661 | if (mutex_lock_interruptible(&pdev->v4l2_lock)) | ||
662 | return -ERESTARTSYS; | ||
785 | /* Turn on camera and set LEDS on */ | 663 | /* Turn on camera and set LEDS on */ |
786 | pwc_camera_power(pdev, 1); | 664 | pwc_camera_power(pdev, 1); |
787 | pwc_set_leds(pdev, leds[0], leds[1]); | 665 | pwc_set_leds(pdev, leds[0], leds[1]); |
@@ -794,6 +672,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) | |||
794 | /* And cleanup any queued bufs!! */ | 672 | /* And cleanup any queued bufs!! */ |
795 | pwc_cleanup_queued_bufs(pdev); | 673 | pwc_cleanup_queued_bufs(pdev); |
796 | } | 674 | } |
675 | mutex_unlock(&pdev->v4l2_lock); | ||
797 | 676 | ||
798 | return r; | 677 | return r; |
799 | } | 678 | } |
@@ -802,6 +681,8 @@ static int stop_streaming(struct vb2_queue *vq) | |||
802 | { | 681 | { |
803 | struct pwc_device *pdev = vb2_get_drv_priv(vq); | 682 | struct pwc_device *pdev = vb2_get_drv_priv(vq); |
804 | 683 | ||
684 | if (mutex_lock_interruptible(&pdev->v4l2_lock)) | ||
685 | return -ERESTARTSYS; | ||
805 | if (pdev->udev) { | 686 | if (pdev->udev) { |
806 | pwc_set_leds(pdev, 0, 0); | 687 | pwc_set_leds(pdev, 0, 0); |
807 | pwc_camera_power(pdev, 0); | 688 | pwc_camera_power(pdev, 0); |
@@ -809,22 +690,11 @@ static int stop_streaming(struct vb2_queue *vq) | |||
809 | } | 690 | } |
810 | 691 | ||
811 | pwc_cleanup_queued_bufs(pdev); | 692 | pwc_cleanup_queued_bufs(pdev); |
693 | mutex_unlock(&pdev->v4l2_lock); | ||
812 | 694 | ||
813 | return 0; | 695 | return 0; |
814 | } | 696 | } |
815 | 697 | ||
816 | static void wait_prepare(struct vb2_queue *vq) | ||
817 | { | ||
818 | struct pwc_device *pdev = vb2_get_drv_priv(vq); | ||
819 | mutex_unlock(&pdev->vb_queue_lock); | ||
820 | } | ||
821 | |||
822 | static void wait_finish(struct vb2_queue *vq) | ||
823 | { | ||
824 | struct pwc_device *pdev = vb2_get_drv_priv(vq); | ||
825 | mutex_lock(&pdev->vb_queue_lock); | ||
826 | } | ||
827 | |||
828 | static struct vb2_ops pwc_vb_queue_ops = { | 698 | static struct vb2_ops pwc_vb_queue_ops = { |
829 | .queue_setup = queue_setup, | 699 | .queue_setup = queue_setup, |
830 | .buf_init = buffer_init, | 700 | .buf_init = buffer_init, |
@@ -834,8 +704,8 @@ static struct vb2_ops pwc_vb_queue_ops = { | |||
834 | .buf_queue = buffer_queue, | 704 | .buf_queue = buffer_queue, |
835 | .start_streaming = start_streaming, | 705 | .start_streaming = start_streaming, |
836 | .stop_streaming = stop_streaming, | 706 | .stop_streaming = stop_streaming, |
837 | .wait_prepare = wait_prepare, | 707 | .wait_prepare = vb2_ops_wait_prepare, |
838 | .wait_finish = wait_finish, | 708 | .wait_finish = vb2_ops_wait_finish, |
839 | }; | 709 | }; |
840 | 710 | ||
841 | /***************************************************************************/ | 711 | /***************************************************************************/ |
@@ -1136,6 +1006,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1136 | /* Init video_device structure */ | 1006 | /* Init video_device structure */ |
1137 | memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template)); | 1007 | memcpy(&pdev->vdev, &pwc_template, sizeof(pwc_template)); |
1138 | strcpy(pdev->vdev.name, name); | 1008 | strcpy(pdev->vdev.name, name); |
1009 | pdev->vdev.queue = &pdev->vb_queue; | ||
1010 | pdev->vdev.queue->lock = &pdev->vb_queue_lock; | ||
1139 | set_bit(V4L2_FL_USE_FH_PRIO, &pdev->vdev.flags); | 1011 | set_bit(V4L2_FL_USE_FH_PRIO, &pdev->vdev.flags); |
1140 | video_set_drvdata(&pdev->vdev, pdev); | 1012 | video_set_drvdata(&pdev->vdev, pdev); |
1141 | 1013 | ||
@@ -1190,15 +1062,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id | |||
1190 | pdev->vdev.v4l2_dev = &pdev->v4l2_dev; | 1062 | pdev->vdev.v4l2_dev = &pdev->v4l2_dev; |
1191 | pdev->vdev.lock = &pdev->v4l2_lock; | 1063 | pdev->vdev.lock = &pdev->v4l2_lock; |
1192 | 1064 | ||
1193 | /* | ||
1194 | * Don't take v4l2_lock for these ioctls. This improves latency if | ||
1195 | * v4l2_lock is taken for a long time, e.g. when changing a control | ||
1196 | * value, and a new frame is ready to be dequeued. | ||
1197 | */ | ||
1198 | v4l2_disable_ioctl_locking(&pdev->vdev, VIDIOC_DQBUF); | ||
1199 | v4l2_disable_ioctl_locking(&pdev->vdev, VIDIOC_QBUF); | ||
1200 | v4l2_disable_ioctl_locking(&pdev->vdev, VIDIOC_QUERYBUF); | ||
1201 | |||
1202 | rc = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, -1); | 1065 | rc = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, -1); |
1203 | if (rc < 0) { | 1066 | if (rc < 0) { |
1204 | PWC_ERROR("Failed to register as video device (%d).\n", rc); | 1067 | PWC_ERROR("Failed to register as video device (%d).\n", rc); |
@@ -1253,20 +1116,18 @@ static void usb_pwc_disconnect(struct usb_interface *intf) | |||
1253 | struct v4l2_device *v = usb_get_intfdata(intf); | 1116 | struct v4l2_device *v = usb_get_intfdata(intf); |
1254 | struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); | 1117 | struct pwc_device *pdev = container_of(v, struct pwc_device, v4l2_dev); |
1255 | 1118 | ||
1256 | mutex_lock(&pdev->v4l2_lock); | ||
1257 | |||
1258 | mutex_lock(&pdev->vb_queue_lock); | 1119 | mutex_lock(&pdev->vb_queue_lock); |
1120 | mutex_lock(&pdev->v4l2_lock); | ||
1259 | /* No need to keep the urbs around after disconnection */ | 1121 | /* No need to keep the urbs around after disconnection */ |
1260 | if (pdev->vb_queue.streaming) | 1122 | if (pdev->vb_queue.streaming) |
1261 | pwc_isoc_cleanup(pdev); | 1123 | pwc_isoc_cleanup(pdev); |
1262 | pdev->udev = NULL; | 1124 | pdev->udev = NULL; |
1263 | pwc_cleanup_queued_bufs(pdev); | 1125 | pwc_cleanup_queued_bufs(pdev); |
1264 | mutex_unlock(&pdev->vb_queue_lock); | ||
1265 | 1126 | ||
1266 | v4l2_device_disconnect(&pdev->v4l2_dev); | 1127 | v4l2_device_disconnect(&pdev->v4l2_dev); |
1267 | video_unregister_device(&pdev->vdev); | 1128 | video_unregister_device(&pdev->vdev); |
1268 | |||
1269 | mutex_unlock(&pdev->v4l2_lock); | 1129 | mutex_unlock(&pdev->v4l2_lock); |
1130 | mutex_unlock(pdev->vb_queue.lock); | ||
1270 | 1131 | ||
1271 | #ifdef CONFIG_USB_PWC_INPUT_EVDEV | 1132 | #ifdef CONFIG_USB_PWC_INPUT_EVDEV |
1272 | if (pdev->button_dev) | 1133 | if (pdev->button_dev) |
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index c691e29cc36e..545e9bbdeede 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c | |||
@@ -405,6 +405,7 @@ static void pwc_vidioc_fill_fmt(struct v4l2_format *f, | |||
405 | f->fmt.pix.pixelformat = pixfmt; | 405 | f->fmt.pix.pixelformat = pixfmt; |
406 | f->fmt.pix.bytesperline = f->fmt.pix.width; | 406 | f->fmt.pix.bytesperline = f->fmt.pix.width; |
407 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.width * 3 / 2; | 407 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.width * 3 / 2; |
408 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; | ||
408 | PWC_DEBUG_IOCTL("pwc_vidioc_fill_fmt() " | 409 | PWC_DEBUG_IOCTL("pwc_vidioc_fill_fmt() " |
409 | "width=%d, height=%d, bytesperline=%d, sizeimage=%d, pixelformat=%c%c%c%c\n", | 410 | "width=%d, height=%d, bytesperline=%d, sizeimage=%d, pixelformat=%c%c%c%c\n", |
410 | f->fmt.pix.width, | 411 | f->fmt.pix.width, |
@@ -468,17 +469,8 @@ static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) | |||
468 | if (ret < 0) | 469 | if (ret < 0) |
469 | return ret; | 470 | return ret; |
470 | 471 | ||
471 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | 472 | if (vb2_is_busy(&pdev->vb_queue)) |
472 | return -ERESTARTSYS; | 473 | return -EBUSY; |
473 | |||
474 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
475 | if (ret) | ||
476 | goto leave; | ||
477 | |||
478 | if (pdev->vb_queue.streaming) { | ||
479 | ret = -EBUSY; | ||
480 | goto leave; | ||
481 | } | ||
482 | 474 | ||
483 | pixelformat = f->fmt.pix.pixelformat; | 475 | pixelformat = f->fmt.pix.pixelformat; |
484 | 476 | ||
@@ -496,8 +488,6 @@ static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) | |||
496 | PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret); | 488 | PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret); |
497 | 489 | ||
498 | pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt); | 490 | pwc_vidioc_fill_fmt(f, pdev->width, pdev->height, pdev->pixfmt); |
499 | leave: | ||
500 | mutex_unlock(&pdev->vb_queue_lock); | ||
501 | return ret; | 491 | return ret; |
502 | } | 492 | } |
503 | 493 | ||
@@ -508,10 +498,9 @@ static int pwc_querycap(struct file *file, void *fh, struct v4l2_capability *cap | |||
508 | strcpy(cap->driver, PWC_NAME); | 498 | strcpy(cap->driver, PWC_NAME); |
509 | strlcpy(cap->card, pdev->vdev.name, sizeof(cap->card)); | 499 | strlcpy(cap->card, pdev->vdev.name, sizeof(cap->card)); |
510 | usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info)); | 500 | usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info)); |
511 | cap->capabilities = | 501 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | |
512 | V4L2_CAP_VIDEO_CAPTURE | | 502 | V4L2_CAP_READWRITE; |
513 | V4L2_CAP_STREAMING | | 503 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; |
514 | V4L2_CAP_READWRITE; | ||
515 | return 0; | 504 | return 0; |
516 | } | 505 | } |
517 | 506 | ||
@@ -520,7 +509,8 @@ static int pwc_enum_input(struct file *file, void *fh, struct v4l2_input *i) | |||
520 | if (i->index) /* Only one INPUT is supported */ | 509 | if (i->index) /* Only one INPUT is supported */ |
521 | return -EINVAL; | 510 | return -EINVAL; |
522 | 511 | ||
523 | strcpy(i->name, "usb"); | 512 | strlcpy(i->name, "Camera", sizeof(i->name)); |
513 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
524 | return 0; | 514 | return 0; |
525 | } | 515 | } |
526 | 516 | ||
@@ -933,104 +923,6 @@ static int pwc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format * | |||
933 | return pwc_vidioc_try_fmt(pdev, f); | 923 | return pwc_vidioc_try_fmt(pdev, f); |
934 | } | 924 | } |
935 | 925 | ||
936 | static int pwc_reqbufs(struct file *file, void *fh, | ||
937 | struct v4l2_requestbuffers *rb) | ||
938 | { | ||
939 | struct pwc_device *pdev = video_drvdata(file); | ||
940 | int ret; | ||
941 | |||
942 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
943 | return -ERESTARTSYS; | ||
944 | |||
945 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
946 | if (ret == 0) | ||
947 | ret = vb2_reqbufs(&pdev->vb_queue, rb); | ||
948 | |||
949 | mutex_unlock(&pdev->vb_queue_lock); | ||
950 | return ret; | ||
951 | } | ||
952 | |||
953 | static int pwc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) | ||
954 | { | ||
955 | struct pwc_device *pdev = video_drvdata(file); | ||
956 | int ret; | ||
957 | |||
958 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
959 | return -ERESTARTSYS; | ||
960 | |||
961 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
962 | if (ret == 0) | ||
963 | ret = vb2_querybuf(&pdev->vb_queue, buf); | ||
964 | |||
965 | mutex_unlock(&pdev->vb_queue_lock); | ||
966 | return ret; | ||
967 | } | ||
968 | |||
969 | static int pwc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | ||
970 | { | ||
971 | struct pwc_device *pdev = video_drvdata(file); | ||
972 | int ret; | ||
973 | |||
974 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
975 | return -ERESTARTSYS; | ||
976 | |||
977 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
978 | if (ret == 0) | ||
979 | ret = vb2_qbuf(&pdev->vb_queue, buf); | ||
980 | |||
981 | mutex_unlock(&pdev->vb_queue_lock); | ||
982 | return ret; | ||
983 | } | ||
984 | |||
985 | static int pwc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | ||
986 | { | ||
987 | struct pwc_device *pdev = video_drvdata(file); | ||
988 | int ret; | ||
989 | |||
990 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
991 | return -ERESTARTSYS; | ||
992 | |||
993 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
994 | if (ret == 0) | ||
995 | ret = vb2_dqbuf(&pdev->vb_queue, buf, | ||
996 | file->f_flags & O_NONBLOCK); | ||
997 | |||
998 | mutex_unlock(&pdev->vb_queue_lock); | ||
999 | return ret; | ||
1000 | } | ||
1001 | |||
1002 | static int pwc_streamon(struct file *file, void *fh, enum v4l2_buf_type i) | ||
1003 | { | ||
1004 | struct pwc_device *pdev = video_drvdata(file); | ||
1005 | int ret; | ||
1006 | |||
1007 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
1008 | return -ERESTARTSYS; | ||
1009 | |||
1010 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
1011 | if (ret == 0) | ||
1012 | ret = vb2_streamon(&pdev->vb_queue, i); | ||
1013 | |||
1014 | mutex_unlock(&pdev->vb_queue_lock); | ||
1015 | return ret; | ||
1016 | } | ||
1017 | |||
1018 | static int pwc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i) | ||
1019 | { | ||
1020 | struct pwc_device *pdev = video_drvdata(file); | ||
1021 | int ret; | ||
1022 | |||
1023 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | ||
1024 | return -ERESTARTSYS; | ||
1025 | |||
1026 | ret = pwc_test_n_set_capt_file(pdev, file); | ||
1027 | if (ret == 0) | ||
1028 | ret = vb2_streamoff(&pdev->vb_queue, i); | ||
1029 | |||
1030 | mutex_unlock(&pdev->vb_queue_lock); | ||
1031 | return ret; | ||
1032 | } | ||
1033 | |||
1034 | static int pwc_enum_framesizes(struct file *file, void *fh, | 926 | static int pwc_enum_framesizes(struct file *file, void *fh, |
1035 | struct v4l2_frmsizeenum *fsize) | 927 | struct v4l2_frmsizeenum *fsize) |
1036 | { | 928 | { |
@@ -1112,32 +1004,27 @@ static int pwc_s_parm(struct file *file, void *fh, | |||
1112 | int compression = 0; | 1004 | int compression = 0; |
1113 | int ret, fps; | 1005 | int ret, fps; |
1114 | 1006 | ||
1115 | if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1007 | if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1116 | parm->parm.capture.timeperframe.numerator == 0) | ||
1117 | return -EINVAL; | 1008 | return -EINVAL; |
1118 | 1009 | ||
1119 | fps = parm->parm.capture.timeperframe.denominator / | 1010 | /* If timeperframe == 0, then reset the framerate to the nominal value. |
1120 | parm->parm.capture.timeperframe.numerator; | 1011 | We pick a high framerate here, and let pwc_set_video_mode() figure |
1121 | 1012 | out the best match. */ | |
1122 | if (mutex_lock_interruptible(&pdev->vb_queue_lock)) | 1013 | if (parm->parm.capture.timeperframe.numerator == 0 || |
1123 | return -ERESTARTSYS; | 1014 | parm->parm.capture.timeperframe.denominator == 0) |
1015 | fps = 30; | ||
1016 | else | ||
1017 | fps = parm->parm.capture.timeperframe.denominator / | ||
1018 | parm->parm.capture.timeperframe.numerator; | ||
1124 | 1019 | ||
1125 | ret = pwc_test_n_set_capt_file(pdev, file); | 1020 | if (vb2_is_busy(&pdev->vb_queue)) |
1126 | if (ret) | 1021 | return -EBUSY; |
1127 | goto leave; | ||
1128 | |||
1129 | if (pdev->vb_queue.streaming) { | ||
1130 | ret = -EBUSY; | ||
1131 | goto leave; | ||
1132 | } | ||
1133 | 1022 | ||
1134 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, | 1023 | ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, |
1135 | fps, &compression, 0); | 1024 | fps, &compression, 0); |
1136 | 1025 | ||
1137 | pwc_g_parm(file, fh, parm); | 1026 | pwc_g_parm(file, fh, parm); |
1138 | 1027 | ||
1139 | leave: | ||
1140 | mutex_unlock(&pdev->vb_queue_lock); | ||
1141 | return ret; | 1028 | return ret; |
1142 | } | 1029 | } |
1143 | 1030 | ||
@@ -1150,12 +1037,12 @@ const struct v4l2_ioctl_ops pwc_ioctl_ops = { | |||
1150 | .vidioc_g_fmt_vid_cap = pwc_g_fmt_vid_cap, | 1037 | .vidioc_g_fmt_vid_cap = pwc_g_fmt_vid_cap, |
1151 | .vidioc_s_fmt_vid_cap = pwc_s_fmt_vid_cap, | 1038 | .vidioc_s_fmt_vid_cap = pwc_s_fmt_vid_cap, |
1152 | .vidioc_try_fmt_vid_cap = pwc_try_fmt_vid_cap, | 1039 | .vidioc_try_fmt_vid_cap = pwc_try_fmt_vid_cap, |
1153 | .vidioc_reqbufs = pwc_reqbufs, | 1040 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1154 | .vidioc_querybuf = pwc_querybuf, | 1041 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1155 | .vidioc_qbuf = pwc_qbuf, | 1042 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1156 | .vidioc_dqbuf = pwc_dqbuf, | 1043 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
1157 | .vidioc_streamon = pwc_streamon, | 1044 | .vidioc_streamon = vb2_ioctl_streamon, |
1158 | .vidioc_streamoff = pwc_streamoff, | 1045 | .vidioc_streamoff = vb2_ioctl_streamoff, |
1159 | .vidioc_log_status = v4l2_ctrl_log_status, | 1046 | .vidioc_log_status = v4l2_ctrl_log_status, |
1160 | .vidioc_enum_framesizes = pwc_enum_framesizes, | 1047 | .vidioc_enum_framesizes = pwc_enum_framesizes, |
1161 | .vidioc_enum_frameintervals = pwc_enum_frameintervals, | 1048 | .vidioc_enum_frameintervals = pwc_enum_frameintervals, |
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h index d6b5b216b9d6..7a6a0d39c2c6 100644 --- a/drivers/media/video/pwc/pwc.h +++ b/drivers/media/video/pwc/pwc.h | |||
@@ -239,7 +239,6 @@ struct pwc_device | |||
239 | int features; /* feature bits */ | 239 | int features; /* feature bits */ |
240 | 240 | ||
241 | /*** Video data ***/ | 241 | /*** Video data ***/ |
242 | struct file *capt_file; /* file doing video capture */ | ||
243 | int vendpoint; /* video isoc endpoint */ | 242 | int vendpoint; /* video isoc endpoint */ |
244 | int vcinterface; /* video control interface */ | 243 | int vcinterface; /* video control interface */ |
245 | int valternate; /* alternate interface needed */ | 244 | int valternate; /* alternate interface needed */ |
@@ -355,8 +354,6 @@ struct pwc_device | |||
355 | extern int pwc_trace; | 354 | extern int pwc_trace; |
356 | #endif | 355 | #endif |
357 | 356 | ||
358 | int pwc_test_n_set_capt_file(struct pwc_device *pdev, struct file *file); | ||
359 | |||
360 | /** Functions in pwc-misc.c */ | 357 | /** Functions in pwc-misc.c */ |
361 | /* sizes in pixels */ | 358 | /* sizes in pixels */ |
362 | extern const int pwc_image_sizes[PSZ_MAX][2]; | 359 | extern const int pwc_image_sizes[PSZ_MAX][2]; |
diff --git a/drivers/media/video/s5p-fimc/fimc-capture.c b/drivers/media/video/s5p-fimc/fimc-capture.c index 725812aa0c30..6a34183564d2 100644 --- a/drivers/media/video/s5p-fimc/fimc-capture.c +++ b/drivers/media/video/s5p-fimc/fimc-capture.c | |||
@@ -658,7 +658,7 @@ static void fimc_capture_try_selection(struct fimc_ctx *ctx, | |||
658 | r->left = r->top = 0; | 658 | r->left = r->top = 0; |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | if (target == V4L2_SEL_TGT_COMPOSE_ACTIVE) { | 661 | if (target == V4L2_SEL_TGT_COMPOSE) { |
662 | if (ctx->rotation != 90 && ctx->rotation != 270) | 662 | if (ctx->rotation != 90 && ctx->rotation != 270) |
663 | align_h = 1; | 663 | align_h = 1; |
664 | max_sc_h = min(SCALER_MAX_HRATIO, 1 << (ffs(sink->width) - 3)); | 664 | max_sc_h = min(SCALER_MAX_HRATIO, 1 << (ffs(sink->width) - 3)); |
@@ -685,7 +685,7 @@ static void fimc_capture_try_selection(struct fimc_ctx *ctx, | |||
685 | rotate ? sink->f_height : sink->f_width); | 685 | rotate ? sink->f_height : sink->f_width); |
686 | max_h = min_t(u32, FIMC_CAMIF_MAX_HEIGHT, sink->f_height); | 686 | max_h = min_t(u32, FIMC_CAMIF_MAX_HEIGHT, sink->f_height); |
687 | 687 | ||
688 | if (target == V4L2_SEL_TGT_COMPOSE_ACTIVE) { | 688 | if (target == V4L2_SEL_TGT_COMPOSE) { |
689 | min_w = min_t(u32, max_w, sink->f_width / max_sc_h); | 689 | min_w = min_t(u32, max_w, sink->f_width / max_sc_h); |
690 | min_h = min_t(u32, max_h, sink->f_height / max_sc_v); | 690 | min_h = min_t(u32, max_h, sink->f_height / max_sc_v); |
691 | if (rotate) { | 691 | if (rotate) { |
@@ -1146,9 +1146,9 @@ static int fimc_cap_g_selection(struct file *file, void *fh, | |||
1146 | s->r.height = f->o_height; | 1146 | s->r.height = f->o_height; |
1147 | return 0; | 1147 | return 0; |
1148 | 1148 | ||
1149 | case V4L2_SEL_TGT_COMPOSE_ACTIVE: | 1149 | case V4L2_SEL_TGT_COMPOSE: |
1150 | f = &ctx->d_frame; | 1150 | f = &ctx->d_frame; |
1151 | case V4L2_SEL_TGT_CROP_ACTIVE: | 1151 | case V4L2_SEL_TGT_CROP: |
1152 | s->r.left = f->offs_h; | 1152 | s->r.left = f->offs_h; |
1153 | s->r.top = f->offs_v; | 1153 | s->r.top = f->offs_v; |
1154 | s->r.width = f->width; | 1154 | s->r.width = f->width; |
@@ -1160,7 +1160,7 @@ static int fimc_cap_g_selection(struct file *file, void *fh, | |||
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | /* Return 1 if rectangle a is enclosed in rectangle b, or 0 otherwise. */ | 1162 | /* Return 1 if rectangle a is enclosed in rectangle b, or 0 otherwise. */ |
1163 | int enclosed_rectangle(struct v4l2_rect *a, struct v4l2_rect *b) | 1163 | static int enclosed_rectangle(struct v4l2_rect *a, struct v4l2_rect *b) |
1164 | { | 1164 | { |
1165 | if (a->left < b->left || a->top < b->top) | 1165 | if (a->left < b->left || a->top < b->top) |
1166 | return 0; | 1166 | return 0; |
@@ -1184,9 +1184,9 @@ static int fimc_cap_s_selection(struct file *file, void *fh, | |||
1184 | if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) | 1184 | if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) |
1185 | return -EINVAL; | 1185 | return -EINVAL; |
1186 | 1186 | ||
1187 | if (s->target == V4L2_SEL_TGT_COMPOSE_ACTIVE) | 1187 | if (s->target == V4L2_SEL_TGT_COMPOSE) |
1188 | f = &ctx->d_frame; | 1188 | f = &ctx->d_frame; |
1189 | else if (s->target == V4L2_SEL_TGT_CROP_ACTIVE) | 1189 | else if (s->target == V4L2_SEL_TGT_CROP) |
1190 | f = &ctx->s_frame; | 1190 | f = &ctx->s_frame; |
1191 | else | 1191 | else |
1192 | return -EINVAL; | 1192 | return -EINVAL; |
@@ -1428,9 +1428,9 @@ static int fimc_subdev_get_selection(struct v4l2_subdev *sd, | |||
1428 | mutex_lock(&fimc->lock); | 1428 | mutex_lock(&fimc->lock); |
1429 | 1429 | ||
1430 | switch (sel->target) { | 1430 | switch (sel->target) { |
1431 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS: | 1431 | case V4L2_SEL_TGT_COMPOSE_BOUNDS: |
1432 | f = &ctx->d_frame; | 1432 | f = &ctx->d_frame; |
1433 | case V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS: | 1433 | case V4L2_SEL_TGT_CROP_BOUNDS: |
1434 | r->width = f->o_width; | 1434 | r->width = f->o_width; |
1435 | r->height = f->o_height; | 1435 | r->height = f->o_height; |
1436 | r->left = 0; | 1436 | r->left = 0; |
@@ -1438,10 +1438,10 @@ static int fimc_subdev_get_selection(struct v4l2_subdev *sd, | |||
1438 | mutex_unlock(&fimc->lock); | 1438 | mutex_unlock(&fimc->lock); |
1439 | return 0; | 1439 | return 0; |
1440 | 1440 | ||
1441 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 1441 | case V4L2_SEL_TGT_CROP: |
1442 | try_sel = v4l2_subdev_get_try_crop(fh, sel->pad); | 1442 | try_sel = v4l2_subdev_get_try_crop(fh, sel->pad); |
1443 | break; | 1443 | break; |
1444 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL: | 1444 | case V4L2_SEL_TGT_COMPOSE: |
1445 | try_sel = v4l2_subdev_get_try_compose(fh, sel->pad); | 1445 | try_sel = v4l2_subdev_get_try_compose(fh, sel->pad); |
1446 | f = &ctx->d_frame; | 1446 | f = &ctx->d_frame; |
1447 | break; | 1447 | break; |
@@ -1482,12 +1482,12 @@ static int fimc_subdev_set_selection(struct v4l2_subdev *sd, | |||
1482 | return -EINVAL; | 1482 | return -EINVAL; |
1483 | 1483 | ||
1484 | mutex_lock(&fimc->lock); | 1484 | mutex_lock(&fimc->lock); |
1485 | fimc_capture_try_selection(ctx, r, V4L2_SEL_TGT_CROP_ACTIVE); | 1485 | fimc_capture_try_selection(ctx, r, V4L2_SEL_TGT_CROP); |
1486 | 1486 | ||
1487 | switch (sel->target) { | 1487 | switch (sel->target) { |
1488 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS: | 1488 | case V4L2_SEL_TGT_COMPOSE_BOUNDS: |
1489 | f = &ctx->d_frame; | 1489 | f = &ctx->d_frame; |
1490 | case V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS: | 1490 | case V4L2_SEL_TGT_CROP_BOUNDS: |
1491 | r->width = f->o_width; | 1491 | r->width = f->o_width; |
1492 | r->height = f->o_height; | 1492 | r->height = f->o_height; |
1493 | r->left = 0; | 1493 | r->left = 0; |
@@ -1495,10 +1495,10 @@ static int fimc_subdev_set_selection(struct v4l2_subdev *sd, | |||
1495 | mutex_unlock(&fimc->lock); | 1495 | mutex_unlock(&fimc->lock); |
1496 | return 0; | 1496 | return 0; |
1497 | 1497 | ||
1498 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 1498 | case V4L2_SEL_TGT_CROP: |
1499 | try_sel = v4l2_subdev_get_try_crop(fh, sel->pad); | 1499 | try_sel = v4l2_subdev_get_try_crop(fh, sel->pad); |
1500 | break; | 1500 | break; |
1501 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL: | 1501 | case V4L2_SEL_TGT_COMPOSE: |
1502 | try_sel = v4l2_subdev_get_try_compose(fh, sel->pad); | 1502 | try_sel = v4l2_subdev_get_try_compose(fh, sel->pad); |
1503 | f = &ctx->d_frame; | 1503 | f = &ctx->d_frame; |
1504 | break; | 1504 | break; |
@@ -1514,7 +1514,7 @@ static int fimc_subdev_set_selection(struct v4l2_subdev *sd, | |||
1514 | set_frame_crop(f, r->left, r->top, r->width, r->height); | 1514 | set_frame_crop(f, r->left, r->top, r->width, r->height); |
1515 | set_bit(ST_CAPT_APPLY_CFG, &fimc->state); | 1515 | set_bit(ST_CAPT_APPLY_CFG, &fimc->state); |
1516 | spin_unlock_irqrestore(&fimc->slock, flags); | 1516 | spin_unlock_irqrestore(&fimc->slock, flags); |
1517 | if (sel->target == V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL) | 1517 | if (sel->target == V4L2_SEL_TGT_COMPOSE) |
1518 | ctx->state |= FIMC_COMPOSE; | 1518 | ctx->state |= FIMC_COMPOSE; |
1519 | } | 1519 | } |
1520 | 1520 | ||
diff --git a/drivers/media/video/s5p-fimc/fimc-core.c b/drivers/media/video/s5p-fimc/fimc-core.c index a4646ca1d56f..1a445404e73d 100644 --- a/drivers/media/video/s5p-fimc/fimc-core.c +++ b/drivers/media/video/s5p-fimc/fimc-core.c | |||
@@ -463,7 +463,7 @@ void fimc_prepare_dma_offset(struct fimc_ctx *ctx, struct fimc_frame *f) | |||
463 | f->fmt->color, f->dma_offset.y_h, f->dma_offset.y_v); | 463 | f->fmt->color, f->dma_offset.y_h, f->dma_offset.y_v); |
464 | } | 464 | } |
465 | 465 | ||
466 | int fimc_set_color_effect(struct fimc_ctx *ctx, enum v4l2_colorfx colorfx) | 466 | static int fimc_set_color_effect(struct fimc_ctx *ctx, enum v4l2_colorfx colorfx) |
467 | { | 467 | { |
468 | struct fimc_effect *effect = &ctx->effect; | 468 | struct fimc_effect *effect = &ctx->effect; |
469 | 469 | ||
diff --git a/drivers/media/video/s5p-fimc/fimc-lite-reg.c b/drivers/media/video/s5p-fimc/fimc-lite-reg.c index 419adfb7cdf9..f996e94873f6 100644 --- a/drivers/media/video/s5p-fimc/fimc-lite-reg.c +++ b/drivers/media/video/s5p-fimc/fimc-lite-reg.c | |||
@@ -215,7 +215,7 @@ void flite_hw_set_camera_bus(struct fimc_lite *dev, | |||
215 | flite_hw_set_camera_port(dev, s_info->mux_id); | 215 | flite_hw_set_camera_port(dev, s_info->mux_id); |
216 | } | 216 | } |
217 | 217 | ||
218 | void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f) | 218 | static void flite_hw_set_out_order(struct fimc_lite *dev, struct flite_frame *f) |
219 | { | 219 | { |
220 | static const u32 pixcode[4][2] = { | 220 | static const u32 pixcode[4][2] = { |
221 | { V4L2_MBUS_FMT_YUYV8_2X8, FLITE_REG_CIODMAFMT_YCBYCR }, | 221 | { V4L2_MBUS_FMT_YUYV8_2X8, FLITE_REG_CIODMAFMT_YCBYCR }, |
diff --git a/drivers/media/video/s5p-fimc/fimc-lite.c b/drivers/media/video/s5p-fimc/fimc-lite.c index 74ff310db30c..c5b57e805b68 100644 --- a/drivers/media/video/s5p-fimc/fimc-lite.c +++ b/drivers/media/video/s5p-fimc/fimc-lite.c | |||
@@ -902,7 +902,7 @@ static int fimc_lite_g_selection(struct file *file, void *fh, | |||
902 | sel->r.height = f->f_height; | 902 | sel->r.height = f->f_height; |
903 | return 0; | 903 | return 0; |
904 | 904 | ||
905 | case V4L2_SEL_TGT_COMPOSE_ACTIVE: | 905 | case V4L2_SEL_TGT_COMPOSE: |
906 | sel->r = f->rect; | 906 | sel->r = f->rect; |
907 | return 0; | 907 | return 0; |
908 | } | 908 | } |
@@ -919,7 +919,7 @@ static int fimc_lite_s_selection(struct file *file, void *fh, | |||
919 | unsigned long flags; | 919 | unsigned long flags; |
920 | 920 | ||
921 | if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE || | 921 | if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE || |
922 | sel->target != V4L2_SEL_TGT_COMPOSE_ACTIVE) | 922 | sel->target != V4L2_SEL_TGT_COMPOSE) |
923 | return -EINVAL; | 923 | return -EINVAL; |
924 | 924 | ||
925 | fimc_lite_try_compose(fimc, &rect); | 925 | fimc_lite_try_compose(fimc, &rect); |
@@ -1117,9 +1117,9 @@ static int fimc_lite_subdev_get_selection(struct v4l2_subdev *sd, | |||
1117 | struct fimc_lite *fimc = v4l2_get_subdevdata(sd); | 1117 | struct fimc_lite *fimc = v4l2_get_subdevdata(sd); |
1118 | struct flite_frame *f = &fimc->inp_frame; | 1118 | struct flite_frame *f = &fimc->inp_frame; |
1119 | 1119 | ||
1120 | if ((sel->target != V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL && | 1120 | if ((sel->target != V4L2_SEL_TGT_CROP && |
1121 | sel->target != V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS) || | 1121 | sel->target != V4L2_SEL_TGT_CROP_BOUNDS) || |
1122 | sel->pad != FLITE_SD_PAD_SINK) | 1122 | sel->pad != FLITE_SD_PAD_SINK) |
1123 | return -EINVAL; | 1123 | return -EINVAL; |
1124 | 1124 | ||
1125 | if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { | 1125 | if (sel->which == V4L2_SUBDEV_FORMAT_TRY) { |
@@ -1128,7 +1128,7 @@ static int fimc_lite_subdev_get_selection(struct v4l2_subdev *sd, | |||
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | mutex_lock(&fimc->lock); | 1130 | mutex_lock(&fimc->lock); |
1131 | if (sel->target == V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL) { | 1131 | if (sel->target == V4L2_SEL_TGT_CROP) { |
1132 | sel->r = f->rect; | 1132 | sel->r = f->rect; |
1133 | } else { | 1133 | } else { |
1134 | sel->r.left = 0; | 1134 | sel->r.left = 0; |
@@ -1153,8 +1153,7 @@ static int fimc_lite_subdev_set_selection(struct v4l2_subdev *sd, | |||
1153 | struct flite_frame *f = &fimc->inp_frame; | 1153 | struct flite_frame *f = &fimc->inp_frame; |
1154 | int ret = 0; | 1154 | int ret = 0; |
1155 | 1155 | ||
1156 | if (sel->target != V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL || | 1156 | if (sel->target != V4L2_SEL_TGT_CROP || sel->pad != FLITE_SD_PAD_SINK) |
1157 | sel->pad != FLITE_SD_PAD_SINK) | ||
1158 | return -EINVAL; | 1157 | return -EINVAL; |
1159 | 1158 | ||
1160 | mutex_lock(&fimc->lock); | 1159 | mutex_lock(&fimc->lock); |
diff --git a/drivers/media/video/s5p-fimc/fimc-mdevice.c b/drivers/media/video/s5p-fimc/fimc-mdevice.c index 52cef4865423..e65bb283fd8a 100644 --- a/drivers/media/video/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/video/s5p-fimc/fimc-mdevice.c | |||
@@ -180,7 +180,7 @@ EXPORT_SYMBOL_GPL(fimc_pipeline_initialize); | |||
180 | * sensor clock. | 180 | * sensor clock. |
181 | * Called with the graph mutex held. | 181 | * Called with the graph mutex held. |
182 | */ | 182 | */ |
183 | int __fimc_pipeline_shutdown(struct fimc_pipeline *p) | 183 | static int __fimc_pipeline_shutdown(struct fimc_pipeline *p) |
184 | { | 184 | { |
185 | int ret = 0; | 185 | int ret = 0; |
186 | 186 | ||
@@ -1010,7 +1010,7 @@ static struct platform_driver fimc_md_driver = { | |||
1010 | } | 1010 | } |
1011 | }; | 1011 | }; |
1012 | 1012 | ||
1013 | int __init fimc_md_init(void) | 1013 | static int __init fimc_md_init(void) |
1014 | { | 1014 | { |
1015 | int ret; | 1015 | int ret; |
1016 | 1016 | ||
@@ -1021,7 +1021,8 @@ int __init fimc_md_init(void) | |||
1021 | 1021 | ||
1022 | return platform_driver_register(&fimc_md_driver); | 1022 | return platform_driver_register(&fimc_md_driver); |
1023 | } | 1023 | } |
1024 | void __exit fimc_md_exit(void) | 1024 | |
1025 | static void __exit fimc_md_exit(void) | ||
1025 | { | 1026 | { |
1026 | platform_driver_unregister(&fimc_md_driver); | 1027 | platform_driver_unregister(&fimc_md_driver); |
1027 | fimc_unregister_driver(); | 1028 | fimc_unregister_driver(); |
diff --git a/drivers/media/video/s5p-jpeg/jpeg-core.c b/drivers/media/video/s5p-jpeg/jpeg-core.c index 28b5225d94f5..95f23024b17d 100644 --- a/drivers/media/video/s5p-jpeg/jpeg-core.c +++ b/drivers/media/video/s5p-jpeg/jpeg-core.c | |||
@@ -824,10 +824,10 @@ static int s5p_jpeg_g_selection(struct file *file, void *priv, | |||
824 | 824 | ||
825 | /* For JPEG blob active == default == bounds */ | 825 | /* For JPEG blob active == default == bounds */ |
826 | switch (s->target) { | 826 | switch (s->target) { |
827 | case V4L2_SEL_TGT_CROP_ACTIVE: | 827 | case V4L2_SEL_TGT_CROP: |
828 | case V4L2_SEL_TGT_CROP_BOUNDS: | 828 | case V4L2_SEL_TGT_CROP_BOUNDS: |
829 | case V4L2_SEL_TGT_CROP_DEFAULT: | 829 | case V4L2_SEL_TGT_CROP_DEFAULT: |
830 | case V4L2_SEL_TGT_COMPOSE_ACTIVE: | 830 | case V4L2_SEL_TGT_COMPOSE: |
831 | case V4L2_SEL_TGT_COMPOSE_DEFAULT: | 831 | case V4L2_SEL_TGT_COMPOSE_DEFAULT: |
832 | s->r.width = ctx->out_q.w; | 832 | s->r.width = ctx->out_q.w; |
833 | s->r.height = ctx->out_q.h; | 833 | s->r.height = ctx->out_q.h; |
@@ -1503,29 +1503,7 @@ static struct platform_driver s5p_jpeg_driver = { | |||
1503 | }, | 1503 | }, |
1504 | }; | 1504 | }; |
1505 | 1505 | ||
1506 | static int __init | 1506 | module_platform_driver(s5p_jpeg_driver); |
1507 | s5p_jpeg_register(void) | ||
1508 | { | ||
1509 | int ret; | ||
1510 | |||
1511 | pr_info("S5P JPEG V4L2 Driver, (c) 2011 Samsung Electronics\n"); | ||
1512 | |||
1513 | ret = platform_driver_register(&s5p_jpeg_driver); | ||
1514 | |||
1515 | if (ret) | ||
1516 | pr_err("%s: failed to register jpeg driver\n", __func__); | ||
1517 | |||
1518 | return ret; | ||
1519 | } | ||
1520 | |||
1521 | static void __exit | ||
1522 | s5p_jpeg_unregister(void) | ||
1523 | { | ||
1524 | platform_driver_unregister(&s5p_jpeg_driver); | ||
1525 | } | ||
1526 | |||
1527 | module_init(s5p_jpeg_register); | ||
1528 | module_exit(s5p_jpeg_unregister); | ||
1529 | 1507 | ||
1530 | MODULE_AUTHOR("Andrzej Pietrasiewicz <andrzej.p@samsung.com>"); | 1508 | MODULE_AUTHOR("Andrzej Pietrasiewicz <andrzej.p@samsung.com>"); |
1531 | MODULE_DESCRIPTION("Samsung JPEG codec driver"); | 1509 | MODULE_DESCRIPTION("Samsung JPEG codec driver"); |
diff --git a/drivers/media/video/s5p-tv/mixer_video.c b/drivers/media/video/s5p-tv/mixer_video.c index 33fde2a763ec..6c74b05d1f95 100644 --- a/drivers/media/video/s5p-tv/mixer_video.c +++ b/drivers/media/video/s5p-tv/mixer_video.c | |||
@@ -367,7 +367,7 @@ static int mxr_g_selection(struct file *file, void *fh, | |||
367 | return -EINVAL; | 367 | return -EINVAL; |
368 | 368 | ||
369 | switch (s->target) { | 369 | switch (s->target) { |
370 | case V4L2_SEL_TGT_CROP_ACTIVE: | 370 | case V4L2_SEL_TGT_CROP: |
371 | s->r.left = geo->src.x_offset; | 371 | s->r.left = geo->src.x_offset; |
372 | s->r.top = geo->src.y_offset; | 372 | s->r.top = geo->src.y_offset; |
373 | s->r.width = geo->src.width; | 373 | s->r.width = geo->src.width; |
@@ -380,7 +380,7 @@ static int mxr_g_selection(struct file *file, void *fh, | |||
380 | s->r.width = geo->src.full_width; | 380 | s->r.width = geo->src.full_width; |
381 | s->r.height = geo->src.full_height; | 381 | s->r.height = geo->src.full_height; |
382 | break; | 382 | break; |
383 | case V4L2_SEL_TGT_COMPOSE_ACTIVE: | 383 | case V4L2_SEL_TGT_COMPOSE: |
384 | case V4L2_SEL_TGT_COMPOSE_PADDED: | 384 | case V4L2_SEL_TGT_COMPOSE_PADDED: |
385 | s->r.left = geo->dst.x_offset; | 385 | s->r.left = geo->dst.x_offset; |
386 | s->r.top = geo->dst.y_offset; | 386 | s->r.top = geo->dst.y_offset; |
@@ -449,11 +449,11 @@ static int mxr_s_selection(struct file *file, void *fh, | |||
449 | res.height = geo->dst.full_height; | 449 | res.height = geo->dst.full_height; |
450 | break; | 450 | break; |
451 | 451 | ||
452 | case V4L2_SEL_TGT_CROP_ACTIVE: | 452 | case V4L2_SEL_TGT_CROP: |
453 | target = &geo->src; | 453 | target = &geo->src; |
454 | stage = MXR_GEOMETRY_CROP; | 454 | stage = MXR_GEOMETRY_CROP; |
455 | break; | 455 | break; |
456 | case V4L2_SEL_TGT_COMPOSE_ACTIVE: | 456 | case V4L2_SEL_TGT_COMPOSE: |
457 | case V4L2_SEL_TGT_COMPOSE_PADDED: | 457 | case V4L2_SEL_TGT_COMPOSE_PADDED: |
458 | target = &geo->dst; | 458 | target = &geo->dst; |
459 | stage = MXR_GEOMETRY_COMPOSE; | 459 | stage = MXR_GEOMETRY_COMPOSE; |
diff --git a/drivers/media/video/s5p-tv/sii9234_drv.c b/drivers/media/video/s5p-tv/sii9234_drv.c index 0f31eccd7b80..6d348f90237a 100644 --- a/drivers/media/video/s5p-tv/sii9234_drv.c +++ b/drivers/media/video/s5p-tv/sii9234_drv.c | |||
@@ -419,14 +419,4 @@ static struct i2c_driver sii9234_driver = { | |||
419 | .id_table = sii9234_id, | 419 | .id_table = sii9234_id, |
420 | }; | 420 | }; |
421 | 421 | ||
422 | static int __init sii9234_init(void) | 422 | module_i2c_driver(sii9234_driver); |
423 | { | ||
424 | return i2c_add_driver(&sii9234_driver); | ||
425 | } | ||
426 | module_init(sii9234_init); | ||
427 | |||
428 | static void __exit sii9234_exit(void) | ||
429 | { | ||
430 | i2c_del_driver(&sii9234_driver); | ||
431 | } | ||
432 | module_exit(sii9234_exit); | ||
diff --git a/drivers/media/video/saa7121.h b/drivers/media/video/saa7121.h deleted file mode 100644 index 66967ae37494..000000000000 --- a/drivers/media/video/saa7121.h +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
1 | /* saa7121.h - saa7121 initializations | ||
2 | Copyright (C) 1999 Nathan Laredo (laredo@gnu.org) | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; if not, write to the Free Software | ||
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | |||
18 | */ | ||
19 | #ifndef __SAA7121_H__ | ||
20 | #define __SAA7121_H__ | ||
21 | |||
22 | #define NTSC_BURST_START 0x19 /* 28 */ | ||
23 | #define NTSC_BURST_END 0x1d /* 29 */ | ||
24 | #define NTSC_CHROMA_PHASE 0x67 /* 5a */ | ||
25 | #define NTSC_GAINU 0x76 /* 5b */ | ||
26 | #define NTSC_GAINV 0xa5 /* 5c */ | ||
27 | #define NTSC_BLACK_LEVEL 0x2a /* 5d */ | ||
28 | #define NTSC_BLANKING_LEVEL 0x2e /* 5e */ | ||
29 | #define NTSC_VBI_BLANKING 0x2e /* 5f */ | ||
30 | #define NTSC_DAC_CONTROL 0x11 /* 61 */ | ||
31 | #define NTSC_BURST_AMP 0x3f /* 62 */ | ||
32 | #define NTSC_SUBC3 0x1f /* 63 */ | ||
33 | #define NTSC_SUBC2 0x7c /* 64 */ | ||
34 | #define NTSC_SUBC1 0xf0 /* 65 */ | ||
35 | #define NTSC_SUBC0 0x21 /* 66 */ | ||
36 | #define NTSC_HTRIG 0x72 /* 6c */ | ||
37 | #define NTSC_VTRIG 0x00 /* 6c */ | ||
38 | #define NTSC_MULTI 0x30 /* 6e */ | ||
39 | #define NTSC_CCTTX 0x11 /* 6f */ | ||
40 | #define NTSC_FIRST_ACTIVE 0x12 /* 7a */ | ||
41 | #define NTSC_LAST_ACTIVE 0x02 /* 7b */ | ||
42 | #define NTSC_MSB_VERTICAL 0x40 /* 7c */ | ||
43 | |||
44 | #define PAL_BURST_START 0x21 /* 28 */ | ||
45 | #define PAL_BURST_END 0x1d /* 29 */ | ||
46 | #define PAL_CHROMA_PHASE 0x3f /* 5a */ | ||
47 | #define PAL_GAINU 0x7d /* 5b */ | ||
48 | #define PAL_GAINV 0xaf /* 5c */ | ||
49 | #define PAL_BLACK_LEVEL 0x23 /* 5d */ | ||
50 | #define PAL_BLANKING_LEVEL 0x35 /* 5e */ | ||
51 | #define PAL_VBI_BLANKING 0x35 /* 5f */ | ||
52 | #define PAL_DAC_CONTROL 0x02 /* 61 */ | ||
53 | #define PAL_BURST_AMP 0x2f /* 62 */ | ||
54 | #define PAL_SUBC3 0xcb /* 63 */ | ||
55 | #define PAL_SUBC2 0x8a /* 64 */ | ||
56 | #define PAL_SUBC1 0x09 /* 65 */ | ||
57 | #define PAL_SUBC0 0x2a /* 66 */ | ||
58 | #define PAL_HTRIG 0x86 /* 6c */ | ||
59 | #define PAL_VTRIG 0x04 /* 6d */ | ||
60 | #define PAL_MULTI 0x20 /* 6e */ | ||
61 | #define PAL_CCTTX 0x15 /* 6f */ | ||
62 | #define PAL_FIRST_ACTIVE 0x16 /* 7a */ | ||
63 | #define PAL_LAST_ACTIVE 0x36 /* 7b */ | ||
64 | #define PAL_MSB_VERTICAL 0x40 /* 7c */ | ||
65 | |||
66 | /* Initialization Sequence */ | ||
67 | |||
68 | static __u8 init7121ntsc[] = { | ||
69 | 0x26, 0x0, 0x27, 0x0, | ||
70 | 0x28, NTSC_BURST_START, 0x29, NTSC_BURST_END, | ||
71 | 0x2a, 0x0, 0x2b, 0x0, 0x2c, 0x0, 0x2d, 0x0, | ||
72 | 0x2e, 0x0, 0x2f, 0x0, 0x30, 0x0, 0x31, 0x0, | ||
73 | 0x32, 0x0, 0x33, 0x0, 0x34, 0x0, 0x35, 0x0, | ||
74 | 0x36, 0x0, 0x37, 0x0, 0x38, 0x0, 0x39, 0x0, | ||
75 | 0x3a, 0x03, 0x3b, 0x0, 0x3c, 0x0, 0x3d, 0x0, | ||
76 | 0x3e, 0x0, 0x3f, 0x0, 0x40, 0x0, 0x41, 0x0, | ||
77 | 0x42, 0x0, 0x43, 0x0, 0x44, 0x0, 0x45, 0x0, | ||
78 | 0x46, 0x0, 0x47, 0x0, 0x48, 0x0, 0x49, 0x0, | ||
79 | 0x4a, 0x0, 0x4b, 0x0, 0x4c, 0x0, 0x4d, 0x0, | ||
80 | 0x4e, 0x0, 0x4f, 0x0, 0x50, 0x0, 0x51, 0x0, | ||
81 | 0x52, 0x0, 0x53, 0x0, 0x54, 0x0, 0x55, 0x0, | ||
82 | 0x56, 0x0, 0x57, 0x0, 0x58, 0x0, 0x59, 0x0, | ||
83 | 0x5a, NTSC_CHROMA_PHASE, 0x5b, NTSC_GAINU, | ||
84 | 0x5c, NTSC_GAINV, 0x5d, NTSC_BLACK_LEVEL, | ||
85 | 0x5e, NTSC_BLANKING_LEVEL, 0x5f, NTSC_VBI_BLANKING, | ||
86 | 0x60, 0x0, 0x61, NTSC_DAC_CONTROL, | ||
87 | 0x62, NTSC_BURST_AMP, 0x63, NTSC_SUBC3, | ||
88 | 0x64, NTSC_SUBC2, 0x65, NTSC_SUBC1, | ||
89 | 0x66, NTSC_SUBC0, 0x67, 0x80, 0x68, 0x80, | ||
90 | 0x69, 0x80, 0x6a, 0x80, 0x6b, 0x29, | ||
91 | 0x6c, NTSC_HTRIG, 0x6d, NTSC_VTRIG, | ||
92 | 0x6e, NTSC_MULTI, 0x6f, NTSC_CCTTX, | ||
93 | 0x70, 0xc9, 0x71, 0x68, 0x72, 0x60, 0x73, 0x0, | ||
94 | 0x74, 0x0, 0x75, 0x0, 0x76, 0x0, 0x77, 0x0, | ||
95 | 0x78, 0x0, 0x79, 0x0, 0x7a, NTSC_FIRST_ACTIVE, | ||
96 | 0x7b, NTSC_LAST_ACTIVE, 0x7c, NTSC_MSB_VERTICAL, | ||
97 | 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0 | ||
98 | }; | ||
99 | #define INIT7121LEN (sizeof(init7121ntsc)/2) | ||
100 | |||
101 | static __u8 init7121pal[] = { | ||
102 | 0x26, 0x0, 0x27, 0x0, | ||
103 | 0x28, PAL_BURST_START, 0x29, PAL_BURST_END, | ||
104 | 0x2a, 0x0, 0x2b, 0x0, 0x2c, 0x0, 0x2d, 0x0, | ||
105 | 0x2e, 0x0, 0x2f, 0x0, 0x30, 0x0, 0x31, 0x0, | ||
106 | 0x32, 0x0, 0x33, 0x0, 0x34, 0x0, 0x35, 0x0, | ||
107 | 0x36, 0x0, 0x37, 0x0, 0x38, 0x0, 0x39, 0x0, | ||
108 | 0x3a, 0x03, 0x3b, 0x0, 0x3c, 0x0, 0x3d, 0x0, | ||
109 | 0x3e, 0x0, 0x3f, 0x0, 0x40, 0x0, 0x41, 0x0, | ||
110 | 0x42, 0x0, 0x43, 0x0, 0x44, 0x0, 0x45, 0x0, | ||
111 | 0x46, 0x0, 0x47, 0x0, 0x48, 0x0, 0x49, 0x0, | ||
112 | 0x4a, 0x0, 0x4b, 0x0, 0x4c, 0x0, 0x4d, 0x0, | ||
113 | 0x4e, 0x0, 0x4f, 0x0, 0x50, 0x0, 0x51, 0x0, | ||
114 | 0x52, 0x0, 0x53, 0x0, 0x54, 0x0, 0x55, 0x0, | ||
115 | 0x56, 0x0, 0x57, 0x0, 0x58, 0x0, 0x59, 0x0, | ||
116 | 0x5a, PAL_CHROMA_PHASE, 0x5b, PAL_GAINU, | ||
117 | 0x5c, PAL_GAINV, 0x5d, PAL_BLACK_LEVEL, | ||
118 | 0x5e, PAL_BLANKING_LEVEL, 0x5f, PAL_VBI_BLANKING, | ||
119 | 0x60, 0x0, 0x61, PAL_DAC_CONTROL, | ||
120 | 0x62, PAL_BURST_AMP, 0x63, PAL_SUBC3, | ||
121 | 0x64, PAL_SUBC2, 0x65, PAL_SUBC1, | ||
122 | 0x66, PAL_SUBC0, 0x67, 0x80, 0x68, 0x80, | ||
123 | 0x69, 0x80, 0x6a, 0x80, 0x6b, 0x29, | ||
124 | 0x6c, PAL_HTRIG, 0x6d, PAL_VTRIG, | ||
125 | 0x6e, PAL_MULTI, 0x6f, PAL_CCTTX, | ||
126 | 0x70, 0xc9, 0x71, 0x68, 0x72, 0x60, 0x73, 0x0, | ||
127 | 0x74, 0x0, 0x75, 0x0, 0x76, 0x0, 0x77, 0x0, | ||
128 | 0x78, 0x0, 0x79, 0x0, 0x7a, PAL_FIRST_ACTIVE, | ||
129 | 0x7b, PAL_LAST_ACTIVE, 0x7c, PAL_MSB_VERTICAL, | ||
130 | 0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0 | ||
131 | }; | ||
132 | #endif | ||
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index 5dfd826d734e..cc7f3d6ee966 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
@@ -1282,7 +1282,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1282 | case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: | 1282 | case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: |
1283 | if (configure_tda827x_fe(dev, &tda827x_lifeview_config, | 1283 | if (configure_tda827x_fe(dev, &tda827x_lifeview_config, |
1284 | &tda827x_cfg_0) < 0) | 1284 | &tda827x_cfg_0) < 0) |
1285 | goto dettach_frontend; | 1285 | goto detach_frontend; |
1286 | break; | 1286 | break; |
1287 | case SAA7134_BOARD_PHILIPS_EUROPA: | 1287 | case SAA7134_BOARD_PHILIPS_EUROPA: |
1288 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: | 1288 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
@@ -1322,7 +1322,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1322 | case SAA7134_BOARD_KWORLD_DVBT_210: | 1322 | case SAA7134_BOARD_KWORLD_DVBT_210: |
1323 | if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config, | 1323 | if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config, |
1324 | &tda827x_cfg_2) < 0) | 1324 | &tda827x_cfg_2) < 0) |
1325 | goto dettach_frontend; | 1325 | goto detach_frontend; |
1326 | break; | 1326 | break; |
1327 | case SAA7134_BOARD_HAUPPAUGE_HVR1120: | 1327 | case SAA7134_BOARD_HAUPPAUGE_HVR1120: |
1328 | fe0->dvb.frontend = dvb_attach(tda10048_attach, | 1328 | fe0->dvb.frontend = dvb_attach(tda10048_attach, |
@@ -1340,17 +1340,17 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1340 | case SAA7134_BOARD_PHILIPS_TIGER: | 1340 | case SAA7134_BOARD_PHILIPS_TIGER: |
1341 | if (configure_tda827x_fe(dev, &philips_tiger_config, | 1341 | if (configure_tda827x_fe(dev, &philips_tiger_config, |
1342 | &tda827x_cfg_0) < 0) | 1342 | &tda827x_cfg_0) < 0) |
1343 | goto dettach_frontend; | 1343 | goto detach_frontend; |
1344 | break; | 1344 | break; |
1345 | case SAA7134_BOARD_PINNACLE_PCTV_310i: | 1345 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
1346 | if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, | 1346 | if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, |
1347 | &tda827x_cfg_1) < 0) | 1347 | &tda827x_cfg_1) < 0) |
1348 | goto dettach_frontend; | 1348 | goto detach_frontend; |
1349 | break; | 1349 | break; |
1350 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: | 1350 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: |
1351 | if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, | 1351 | if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, |
1352 | &tda827x_cfg_1) < 0) | 1352 | &tda827x_cfg_1) < 0) |
1353 | goto dettach_frontend; | 1353 | goto detach_frontend; |
1354 | break; | 1354 | break; |
1355 | case SAA7134_BOARD_HAUPPAUGE_HVR1150: | 1355 | case SAA7134_BOARD_HAUPPAUGE_HVR1150: |
1356 | fe0->dvb.frontend = dvb_attach(lgdt3305_attach, | 1356 | fe0->dvb.frontend = dvb_attach(lgdt3305_attach, |
@@ -1368,30 +1368,30 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1368 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: | 1368 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
1369 | if (configure_tda827x_fe(dev, &asus_p7131_dual_config, | 1369 | if (configure_tda827x_fe(dev, &asus_p7131_dual_config, |
1370 | &tda827x_cfg_0) < 0) | 1370 | &tda827x_cfg_0) < 0) |
1371 | goto dettach_frontend; | 1371 | goto detach_frontend; |
1372 | break; | 1372 | break; |
1373 | case SAA7134_BOARD_FLYDVBT_LR301: | 1373 | case SAA7134_BOARD_FLYDVBT_LR301: |
1374 | if (configure_tda827x_fe(dev, &tda827x_lifeview_config, | 1374 | if (configure_tda827x_fe(dev, &tda827x_lifeview_config, |
1375 | &tda827x_cfg_0) < 0) | 1375 | &tda827x_cfg_0) < 0) |
1376 | goto dettach_frontend; | 1376 | goto detach_frontend; |
1377 | break; | 1377 | break; |
1378 | case SAA7134_BOARD_FLYDVB_TRIO: | 1378 | case SAA7134_BOARD_FLYDVB_TRIO: |
1379 | if (!use_frontend) { /* terrestrial */ | 1379 | if (!use_frontend) { /* terrestrial */ |
1380 | if (configure_tda827x_fe(dev, &lifeview_trio_config, | 1380 | if (configure_tda827x_fe(dev, &lifeview_trio_config, |
1381 | &tda827x_cfg_0) < 0) | 1381 | &tda827x_cfg_0) < 0) |
1382 | goto dettach_frontend; | 1382 | goto detach_frontend; |
1383 | } else { /* satellite */ | 1383 | } else { /* satellite */ |
1384 | fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); | 1384 | fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); |
1385 | if (fe0->dvb.frontend) { | 1385 | if (fe0->dvb.frontend) { |
1386 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63, | 1386 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63, |
1387 | &dev->i2c_adap, 0) == NULL) { | 1387 | &dev->i2c_adap, 0) == NULL) { |
1388 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); | 1388 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); |
1389 | goto dettach_frontend; | 1389 | goto detach_frontend; |
1390 | } | 1390 | } |
1391 | if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap, | 1391 | if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap, |
1392 | 0x08, 0, 0) == NULL) { | 1392 | 0x08, 0, 0) == NULL) { |
1393 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); | 1393 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); |
1394 | goto dettach_frontend; | 1394 | goto detach_frontend; |
1395 | } | 1395 | } |
1396 | } | 1396 | } |
1397 | } | 1397 | } |
@@ -1407,7 +1407,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1407 | &ads_duo_cfg) == NULL) { | 1407 | &ads_duo_cfg) == NULL) { |
1408 | wprintk("no tda827x tuner found at addr: %02x\n", | 1408 | wprintk("no tda827x tuner found at addr: %02x\n", |
1409 | ads_tech_duo_config.tuner_address); | 1409 | ads_tech_duo_config.tuner_address); |
1410 | goto dettach_frontend; | 1410 | goto detach_frontend; |
1411 | } | 1411 | } |
1412 | } else | 1412 | } else |
1413 | wprintk("failed to attach tda10046\n"); | 1413 | wprintk("failed to attach tda10046\n"); |
@@ -1415,13 +1415,13 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1415 | case SAA7134_BOARD_TEVION_DVBT_220RF: | 1415 | case SAA7134_BOARD_TEVION_DVBT_220RF: |
1416 | if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config, | 1416 | if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config, |
1417 | &tda827x_cfg_0) < 0) | 1417 | &tda827x_cfg_0) < 0) |
1418 | goto dettach_frontend; | 1418 | goto detach_frontend; |
1419 | break; | 1419 | break; |
1420 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: | 1420 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: |
1421 | if (!use_frontend) { /* terrestrial */ | 1421 | if (!use_frontend) { /* terrestrial */ |
1422 | if (configure_tda827x_fe(dev, &md8800_dvbt_config, | 1422 | if (configure_tda827x_fe(dev, &md8800_dvbt_config, |
1423 | &tda827x_cfg_0) < 0) | 1423 | &tda827x_cfg_0) < 0) |
1424 | goto dettach_frontend; | 1424 | goto detach_frontend; |
1425 | } else { /* satellite */ | 1425 | } else { /* satellite */ |
1426 | fe0->dvb.frontend = dvb_attach(tda10086_attach, | 1426 | fe0->dvb.frontend = dvb_attach(tda10086_attach, |
1427 | &flydvbs, &dev->i2c_adap); | 1427 | &flydvbs, &dev->i2c_adap); |
@@ -1435,7 +1435,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1435 | 0x60, &dev->i2c_adap, 0) == NULL) { | 1435 | 0x60, &dev->i2c_adap, 0) == NULL) { |
1436 | wprintk("%s: Medion Quadro, no tda826x " | 1436 | wprintk("%s: Medion Quadro, no tda826x " |
1437 | "found !\n", __func__); | 1437 | "found !\n", __func__); |
1438 | goto dettach_frontend; | 1438 | goto detach_frontend; |
1439 | } | 1439 | } |
1440 | if (dev_id != 0x08) { | 1440 | if (dev_id != 0x08) { |
1441 | /* we need to open the i2c gate (we know it exists) */ | 1441 | /* we need to open the i2c gate (we know it exists) */ |
@@ -1444,7 +1444,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1444 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { | 1444 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
1445 | wprintk("%s: Medion Quadro, no ISL6405 " | 1445 | wprintk("%s: Medion Quadro, no ISL6405 " |
1446 | "found !\n", __func__); | 1446 | "found !\n", __func__); |
1447 | goto dettach_frontend; | 1447 | goto detach_frontend; |
1448 | } | 1448 | } |
1449 | if (dev_id == 0x07) { | 1449 | if (dev_id == 0x07) { |
1450 | /* fire up the 2nd section of the LNB supply since | 1450 | /* fire up the 2nd section of the LNB supply since |
@@ -1503,12 +1503,12 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1503 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, | 1503 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, |
1504 | &dev->i2c_adap, 0) == NULL) { | 1504 | &dev->i2c_adap, 0) == NULL) { |
1505 | wprintk("%s: No tda826x found!\n", __func__); | 1505 | wprintk("%s: No tda826x found!\n", __func__); |
1506 | goto dettach_frontend; | 1506 | goto detach_frontend; |
1507 | } | 1507 | } |
1508 | if (dvb_attach(isl6421_attach, fe0->dvb.frontend, | 1508 | if (dvb_attach(isl6421_attach, fe0->dvb.frontend, |
1509 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { | 1509 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
1510 | wprintk("%s: No ISL6421 found!\n", __func__); | 1510 | wprintk("%s: No ISL6421 found!\n", __func__); |
1511 | goto dettach_frontend; | 1511 | goto detach_frontend; |
1512 | } | 1512 | } |
1513 | } | 1513 | } |
1514 | break; | 1514 | break; |
@@ -1537,37 +1537,37 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1537 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: | 1537 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: |
1538 | if (configure_tda827x_fe(dev, &cinergy_ht_config, | 1538 | if (configure_tda827x_fe(dev, &cinergy_ht_config, |
1539 | &tda827x_cfg_0) < 0) | 1539 | &tda827x_cfg_0) < 0) |
1540 | goto dettach_frontend; | 1540 | goto detach_frontend; |
1541 | break; | 1541 | break; |
1542 | case SAA7134_BOARD_CINERGY_HT_PCI: | 1542 | case SAA7134_BOARD_CINERGY_HT_PCI: |
1543 | if (configure_tda827x_fe(dev, &cinergy_ht_pci_config, | 1543 | if (configure_tda827x_fe(dev, &cinergy_ht_pci_config, |
1544 | &tda827x_cfg_0) < 0) | 1544 | &tda827x_cfg_0) < 0) |
1545 | goto dettach_frontend; | 1545 | goto detach_frontend; |
1546 | break; | 1546 | break; |
1547 | case SAA7134_BOARD_PHILIPS_TIGER_S: | 1547 | case SAA7134_BOARD_PHILIPS_TIGER_S: |
1548 | if (configure_tda827x_fe(dev, &philips_tiger_s_config, | 1548 | if (configure_tda827x_fe(dev, &philips_tiger_s_config, |
1549 | &tda827x_cfg_2) < 0) | 1549 | &tda827x_cfg_2) < 0) |
1550 | goto dettach_frontend; | 1550 | goto detach_frontend; |
1551 | break; | 1551 | break; |
1552 | case SAA7134_BOARD_ASUS_P7131_4871: | 1552 | case SAA7134_BOARD_ASUS_P7131_4871: |
1553 | if (configure_tda827x_fe(dev, &asus_p7131_4871_config, | 1553 | if (configure_tda827x_fe(dev, &asus_p7131_4871_config, |
1554 | &tda827x_cfg_2) < 0) | 1554 | &tda827x_cfg_2) < 0) |
1555 | goto dettach_frontend; | 1555 | goto detach_frontend; |
1556 | break; | 1556 | break; |
1557 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: | 1557 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
1558 | if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, | 1558 | if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, |
1559 | &tda827x_cfg_2) < 0) | 1559 | &tda827x_cfg_2) < 0) |
1560 | goto dettach_frontend; | 1560 | goto detach_frontend; |
1561 | break; | 1561 | break; |
1562 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: | 1562 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: |
1563 | if (configure_tda827x_fe(dev, &avermedia_super_007_config, | 1563 | if (configure_tda827x_fe(dev, &avermedia_super_007_config, |
1564 | &tda827x_cfg_0) < 0) | 1564 | &tda827x_cfg_0) < 0) |
1565 | goto dettach_frontend; | 1565 | goto detach_frontend; |
1566 | break; | 1566 | break; |
1567 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: | 1567 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: |
1568 | if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, | 1568 | if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, |
1569 | &tda827x_cfg_2_sw42) < 0) | 1569 | &tda827x_cfg_2_sw42) < 0) |
1570 | goto dettach_frontend; | 1570 | goto detach_frontend; |
1571 | break; | 1571 | break; |
1572 | case SAA7134_BOARD_PHILIPS_SNAKE: | 1572 | case SAA7134_BOARD_PHILIPS_SNAKE: |
1573 | fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, | 1573 | fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, |
@@ -1576,24 +1576,24 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1576 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, | 1576 | if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60, |
1577 | &dev->i2c_adap, 0) == NULL) { | 1577 | &dev->i2c_adap, 0) == NULL) { |
1578 | wprintk("%s: No tda826x found!\n", __func__); | 1578 | wprintk("%s: No tda826x found!\n", __func__); |
1579 | goto dettach_frontend; | 1579 | goto detach_frontend; |
1580 | } | 1580 | } |
1581 | if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, | 1581 | if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, |
1582 | &dev->i2c_adap, 0, 0) == NULL) { | 1582 | &dev->i2c_adap, 0, 0) == NULL) { |
1583 | wprintk("%s: No lnbp21 found!\n", __func__); | 1583 | wprintk("%s: No lnbp21 found!\n", __func__); |
1584 | goto dettach_frontend; | 1584 | goto detach_frontend; |
1585 | } | 1585 | } |
1586 | } | 1586 | } |
1587 | break; | 1587 | break; |
1588 | case SAA7134_BOARD_CREATIX_CTX953: | 1588 | case SAA7134_BOARD_CREATIX_CTX953: |
1589 | if (configure_tda827x_fe(dev, &md8800_dvbt_config, | 1589 | if (configure_tda827x_fe(dev, &md8800_dvbt_config, |
1590 | &tda827x_cfg_0) < 0) | 1590 | &tda827x_cfg_0) < 0) |
1591 | goto dettach_frontend; | 1591 | goto detach_frontend; |
1592 | break; | 1592 | break; |
1593 | case SAA7134_BOARD_MSI_TVANYWHERE_AD11: | 1593 | case SAA7134_BOARD_MSI_TVANYWHERE_AD11: |
1594 | if (configure_tda827x_fe(dev, &philips_tiger_s_config, | 1594 | if (configure_tda827x_fe(dev, &philips_tiger_s_config, |
1595 | &tda827x_cfg_2) < 0) | 1595 | &tda827x_cfg_2) < 0) |
1596 | goto dettach_frontend; | 1596 | goto detach_frontend; |
1597 | break; | 1597 | break; |
1598 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | 1598 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: |
1599 | dprintk("AverMedia E506R dvb setup\n"); | 1599 | dprintk("AverMedia E506R dvb setup\n"); |
@@ -1614,7 +1614,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1614 | &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { | 1614 | &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) { |
1615 | wprintk("%s: MD7134 DVB-S, no SD1878 " | 1615 | wprintk("%s: MD7134 DVB-S, no SD1878 " |
1616 | "found !\n", __func__); | 1616 | "found !\n", __func__); |
1617 | goto dettach_frontend; | 1617 | goto detach_frontend; |
1618 | } | 1618 | } |
1619 | /* we need to open the i2c gate (we know it exists) */ | 1619 | /* we need to open the i2c gate (we know it exists) */ |
1620 | fe = fe0->dvb.frontend; | 1620 | fe = fe0->dvb.frontend; |
@@ -1623,7 +1623,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1623 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { | 1623 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
1624 | wprintk("%s: MD7134 DVB-S, no ISL6405 " | 1624 | wprintk("%s: MD7134 DVB-S, no ISL6405 " |
1625 | "found !\n", __func__); | 1625 | "found !\n", __func__); |
1626 | goto dettach_frontend; | 1626 | goto detach_frontend; |
1627 | } | 1627 | } |
1628 | fe->ops.i2c_gate_ctrl(fe, 0); | 1628 | fe->ops.i2c_gate_ctrl(fe, 0); |
1629 | dev->original_set_voltage = fe->ops.set_voltage; | 1629 | dev->original_set_voltage = fe->ops.set_voltage; |
@@ -1645,7 +1645,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1645 | if (!use_frontend) { /* terrestrial */ | 1645 | if (!use_frontend) { /* terrestrial */ |
1646 | if (configure_tda827x_fe(dev, &asus_tiger_3in1_config, | 1646 | if (configure_tda827x_fe(dev, &asus_tiger_3in1_config, |
1647 | &tda827x_cfg_2) < 0) | 1647 | &tda827x_cfg_2) < 0) |
1648 | goto dettach_frontend; | 1648 | goto detach_frontend; |
1649 | } else { /* satellite */ | 1649 | } else { /* satellite */ |
1650 | fe0->dvb.frontend = dvb_attach(tda10086_attach, | 1650 | fe0->dvb.frontend = dvb_attach(tda10086_attach, |
1651 | &flydvbs, &dev->i2c_adap); | 1651 | &flydvbs, &dev->i2c_adap); |
@@ -1655,13 +1655,13 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1655 | &dev->i2c_adap, 0) == NULL) { | 1655 | &dev->i2c_adap, 0) == NULL) { |
1656 | wprintk("%s: Asus Tiger 3in1, no " | 1656 | wprintk("%s: Asus Tiger 3in1, no " |
1657 | "tda826x found!\n", __func__); | 1657 | "tda826x found!\n", __func__); |
1658 | goto dettach_frontend; | 1658 | goto detach_frontend; |
1659 | } | 1659 | } |
1660 | if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, | 1660 | if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, |
1661 | &dev->i2c_adap, 0, 0) == NULL) { | 1661 | &dev->i2c_adap, 0, 0) == NULL) { |
1662 | wprintk("%s: Asus Tiger 3in1, no lnbp21" | 1662 | wprintk("%s: Asus Tiger 3in1, no lnbp21" |
1663 | " found!\n", __func__); | 1663 | " found!\n", __func__); |
1664 | goto dettach_frontend; | 1664 | goto detach_frontend; |
1665 | } | 1665 | } |
1666 | } | 1666 | } |
1667 | } | 1667 | } |
@@ -1670,7 +1670,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1670 | if (!use_frontend) { /* terrestrial */ | 1670 | if (!use_frontend) { /* terrestrial */ |
1671 | if (configure_tda827x_fe(dev, &asus_ps3_100_config, | 1671 | if (configure_tda827x_fe(dev, &asus_ps3_100_config, |
1672 | &tda827x_cfg_2) < 0) | 1672 | &tda827x_cfg_2) < 0) |
1673 | goto dettach_frontend; | 1673 | goto detach_frontend; |
1674 | } else { /* satellite */ | 1674 | } else { /* satellite */ |
1675 | fe0->dvb.frontend = dvb_attach(tda10086_attach, | 1675 | fe0->dvb.frontend = dvb_attach(tda10086_attach, |
1676 | &flydvbs, &dev->i2c_adap); | 1676 | &flydvbs, &dev->i2c_adap); |
@@ -1680,13 +1680,13 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1680 | &dev->i2c_adap, 0) == NULL) { | 1680 | &dev->i2c_adap, 0) == NULL) { |
1681 | wprintk("%s: Asus My Cinema PS3-100, no " | 1681 | wprintk("%s: Asus My Cinema PS3-100, no " |
1682 | "tda826x found!\n", __func__); | 1682 | "tda826x found!\n", __func__); |
1683 | goto dettach_frontend; | 1683 | goto detach_frontend; |
1684 | } | 1684 | } |
1685 | if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, | 1685 | if (dvb_attach(lnbp21_attach, fe0->dvb.frontend, |
1686 | &dev->i2c_adap, 0, 0) == NULL) { | 1686 | &dev->i2c_adap, 0, 0) == NULL) { |
1687 | wprintk("%s: Asus My Cinema PS3-100, no lnbp21" | 1687 | wprintk("%s: Asus My Cinema PS3-100, no lnbp21" |
1688 | " found!\n", __func__); | 1688 | " found!\n", __func__); |
1689 | goto dettach_frontend; | 1689 | goto detach_frontend; |
1690 | } | 1690 | } |
1691 | } | 1691 | } |
1692 | } | 1692 | } |
@@ -1694,7 +1694,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1694 | case SAA7134_BOARD_ASUSTeK_TIGER: | 1694 | case SAA7134_BOARD_ASUSTeK_TIGER: |
1695 | if (configure_tda827x_fe(dev, &philips_tiger_config, | 1695 | if (configure_tda827x_fe(dev, &philips_tiger_config, |
1696 | &tda827x_cfg_0) < 0) | 1696 | &tda827x_cfg_0) < 0) |
1697 | goto dettach_frontend; | 1697 | goto detach_frontend; |
1698 | break; | 1698 | break; |
1699 | case SAA7134_BOARD_BEHOLD_H6: | 1699 | case SAA7134_BOARD_BEHOLD_H6: |
1700 | fe0->dvb.frontend = dvb_attach(zl10353_attach, | 1700 | fe0->dvb.frontend = dvb_attach(zl10353_attach, |
@@ -1830,19 +1830,19 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1830 | }; | 1830 | }; |
1831 | 1831 | ||
1832 | if (!fe0->dvb.frontend) | 1832 | if (!fe0->dvb.frontend) |
1833 | goto dettach_frontend; | 1833 | goto detach_frontend; |
1834 | 1834 | ||
1835 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); | 1835 | fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg); |
1836 | if (!fe) { | 1836 | if (!fe) { |
1837 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | 1837 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", |
1838 | dev->name); | 1838 | dev->name); |
1839 | goto dettach_frontend; | 1839 | goto detach_frontend; |
1840 | } | 1840 | } |
1841 | } | 1841 | } |
1842 | 1842 | ||
1843 | if (NULL == fe0->dvb.frontend) { | 1843 | if (NULL == fe0->dvb.frontend) { |
1844 | printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); | 1844 | printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); |
1845 | goto dettach_frontend; | 1845 | goto detach_frontend; |
1846 | } | 1846 | } |
1847 | /* define general-purpose callback pointer */ | 1847 | /* define general-purpose callback pointer */ |
1848 | fe0->dvb.frontend->callback = saa7134_tuner_callback; | 1848 | fe0->dvb.frontend->callback = saa7134_tuner_callback; |
@@ -1864,7 +1864,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
1864 | } | 1864 | } |
1865 | return ret; | 1865 | return ret; |
1866 | 1866 | ||
1867 | dettach_frontend: | 1867 | detach_frontend: |
1868 | videobuf_dvb_dealloc_frontends(&dev->frontends); | 1868 | videobuf_dvb_dealloc_frontends(&dev->frontends); |
1869 | return -EINVAL; | 1869 | return -EINVAL; |
1870 | } | 1870 | } |
diff --git a/drivers/media/video/saa7146.h b/drivers/media/video/saa7146.h deleted file mode 100644 index 9fadb331a40b..000000000000 --- a/drivers/media/video/saa7146.h +++ /dev/null | |||
@@ -1,112 +0,0 @@ | |||
1 | /* | ||
2 | saa7146.h - definitions philips saa7146 based cards | ||
3 | Copyright (C) 1999 Nathan Laredo (laredo@gnu.org) | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __SAA7146__ | ||
21 | #define __SAA7146__ | ||
22 | |||
23 | #define SAA7146_VERSION_CODE 0x000101 | ||
24 | |||
25 | #include <linux/types.h> | ||
26 | #include <linux/wait.h> | ||
27 | |||
28 | #ifndef O_NONCAP | ||
29 | #define O_NONCAP O_TRUNC | ||
30 | #endif | ||
31 | |||
32 | #define MAX_GBUFFERS 2 | ||
33 | #define FBUF_SIZE 0x190000 | ||
34 | |||
35 | #ifdef __KERNEL__ | ||
36 | |||
37 | struct saa7146_window | ||
38 | { | ||
39 | int x, y; | ||
40 | ushort width, height; | ||
41 | ushort bpp, bpl; | ||
42 | ushort swidth, sheight; | ||
43 | short cropx, cropy; | ||
44 | ushort cropwidth, cropheight; | ||
45 | unsigned long vidadr; | ||
46 | int color_fmt; | ||
47 | ushort depth; | ||
48 | }; | ||
49 | |||
50 | /* Per-open data for handling multiple opens on one device */ | ||
51 | struct device_open | ||
52 | { | ||
53 | int isopen; | ||
54 | int noncapturing; | ||
55 | struct saa7146 *dev; | ||
56 | }; | ||
57 | #define MAX_OPENS 3 | ||
58 | |||
59 | struct saa7146 | ||
60 | { | ||
61 | struct video_device video_dev; | ||
62 | struct video_picture picture; | ||
63 | struct video_audio audio_dev; | ||
64 | struct video_info vidinfo; | ||
65 | int user; | ||
66 | int cap; | ||
67 | int capuser; | ||
68 | int irqstate; /* irq routine is state driven */ | ||
69 | int writemode; | ||
70 | int playmode; | ||
71 | unsigned int nr; | ||
72 | unsigned long irq; /* IRQ used by SAA7146 card */ | ||
73 | unsigned short id; | ||
74 | unsigned char revision; | ||
75 | unsigned char boardcfg[64]; /* 64 bytes of config from eeprom */ | ||
76 | unsigned long saa7146_adr; /* bus address of IO mem from PCI BIOS */ | ||
77 | struct saa7146_window win; | ||
78 | unsigned char __iomem *saa7146_mem; /* pointer to mapped IO memory */ | ||
79 | struct device_open open_data[MAX_OPENS]; | ||
80 | #define MAX_MARKS 16 | ||
81 | /* for a/v sync */ | ||
82 | int endmark[MAX_MARKS], endmarkhead, endmarktail; | ||
83 | u32 *dmaRPS1, *pageRPS1, *dmaRPS2, *pageRPS2, *dmavid1, *dmavid2, | ||
84 | *dmavid3, *dmaa1in, *dmaa1out, *dmaa2in, *dmaa2out, | ||
85 | *pagedebi, *pagevid1, *pagevid2, *pagevid3, *pagea1in, | ||
86 | *pagea1out, *pagea2in, *pagea2out; | ||
87 | wait_queue_head_t i2cq, debiq, audq, vidq; | ||
88 | u8 *vidbuf, *audbuf, *osdbuf, *dmadebi; | ||
89 | int audhead, vidhead, osdhead, audtail, vidtail, osdtail; | ||
90 | spinlock_t lock; /* the device lock */ | ||
91 | }; | ||
92 | #endif | ||
93 | |||
94 | #ifdef _ALPHA_SAA7146 | ||
95 | #define saawrite(dat,adr) writel((dat), saa->saa7146_adr+(adr)) | ||
96 | #define saaread(adr) readl(saa->saa7146_adr+(adr)) | ||
97 | #else | ||
98 | #define saawrite(dat,adr) writel((dat), saa->saa7146_mem+(adr)) | ||
99 | #define saaread(adr) readl(saa->saa7146_mem+(adr)) | ||
100 | #endif | ||
101 | |||
102 | #define saaand(dat,adr) saawrite((dat) & saaread(adr), adr) | ||
103 | #define saaor(dat,adr) saawrite((dat) | saaread(adr), adr) | ||
104 | #define saaaor(dat,mask,adr) saawrite((dat) | ((mask) & saaread(adr)), adr) | ||
105 | |||
106 | /* bitmask of attached hardware found */ | ||
107 | #define SAA7146_UNKNOWN 0x00000000 | ||
108 | #define SAA7146_SAA7111 0x00000001 | ||
109 | #define SAA7146_SAA7121 0x00000002 | ||
110 | #define SAA7146_IBMMPEG 0x00000004 | ||
111 | |||
112 | #endif | ||
diff --git a/drivers/media/video/saa7146reg.h b/drivers/media/video/saa7146reg.h deleted file mode 100644 index 80ec2c146b4c..000000000000 --- a/drivers/media/video/saa7146reg.h +++ /dev/null | |||
@@ -1,283 +0,0 @@ | |||
1 | /* | ||
2 | saa7146.h - definitions philips saa7146 based cards | ||
3 | Copyright (C) 1999 Nathan Laredo (laredo@gnu.org) | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __SAA7146_REG__ | ||
21 | #define __SAA7146_REG__ | ||
22 | #define SAA7146_BASE_ODD1 0x00 | ||
23 | #define SAA7146_BASE_EVEN1 0x04 | ||
24 | #define SAA7146_PROT_ADDR1 0x08 | ||
25 | #define SAA7146_PITCH1 0x0c | ||
26 | #define SAA7146_PAGE1 0x10 | ||
27 | #define SAA7146_NUM_LINE_BYTE1 0x14 | ||
28 | #define SAA7146_BASE_ODD2 0x18 | ||
29 | #define SAA7146_BASE_EVEN2 0x1c | ||
30 | #define SAA7146_PROT_ADDR2 0x20 | ||
31 | #define SAA7146_PITCH2 0x24 | ||
32 | #define SAA7146_PAGE2 0x28 | ||
33 | #define SAA7146_NUM_LINE_BYTE2 0x2c | ||
34 | #define SAA7146_BASE_ODD3 0x30 | ||
35 | #define SAA7146_BASE_EVEN3 0x34 | ||
36 | #define SAA7146_PROT_ADDR3 0x38 | ||
37 | #define SAA7146_PITCH3 0x3c | ||
38 | #define SAA7146_PAGE3 0x40 | ||
39 | #define SAA7146_NUM_LINE_BYTE3 0x44 | ||
40 | #define SAA7146_PCI_BT_V1 0x48 | ||
41 | #define SAA7146_PCI_BT_V2 0x49 | ||
42 | #define SAA7146_PCI_BT_V3 0x4a | ||
43 | #define SAA7146_PCI_BT_DEBI 0x4b | ||
44 | #define SAA7146_PCI_BT_A 0x4c | ||
45 | #define SAA7146_DD1_INIT 0x50 | ||
46 | #define SAA7146_DD1_STREAM_B 0x54 | ||
47 | #define SAA7146_DD1_STREAM_A 0x56 | ||
48 | #define SAA7146_BRS_CTRL 0x58 | ||
49 | #define SAA7146_HPS_CTRL 0x5c | ||
50 | #define SAA7146_HPS_V_SCALE 0x60 | ||
51 | #define SAA7146_HPS_V_GAIN 0x64 | ||
52 | #define SAA7146_HPS_H_PRESCALE 0x68 | ||
53 | #define SAA7146_HPS_H_SCALE 0x6c | ||
54 | #define SAA7146_BCS_CTRL 0x70 | ||
55 | #define SAA7146_CHROMA_KEY_RANGE 0x74 | ||
56 | #define SAA7146_CLIP_FORMAT_CTRL 0x78 | ||
57 | #define SAA7146_DEBI_CONFIG 0x7c | ||
58 | #define SAA7146_DEBI_COMMAND 0x80 | ||
59 | #define SAA7146_DEBI_PAGE 0x84 | ||
60 | #define SAA7146_DEBI_AD 0x88 | ||
61 | #define SAA7146_I2C_TRANSFER 0x8c | ||
62 | #define SAA7146_I2C_STATUS 0x90 | ||
63 | #define SAA7146_BASE_A1_IN 0x94 | ||
64 | #define SAA7146_PROT_A1_IN 0x98 | ||
65 | #define SAA7146_PAGE_A1_IN 0x9C | ||
66 | #define SAA7146_BASE_A1_OUT 0xa0 | ||
67 | #define SAA7146_PROT_A1_OUT 0xa4 | ||
68 | #define SAA7146_PAGE_A1_OUT 0xa8 | ||
69 | #define SAA7146_BASE_A2_IN 0xac | ||
70 | #define SAA7146_PROT_A2_IN 0xb0 | ||
71 | #define SAA7146_PAGE_A2_IN 0xb4 | ||
72 | #define SAA7146_BASE_A2_OUT 0xb8 | ||
73 | #define SAA7146_PROT_A2_OUT 0xbc | ||
74 | #define SAA7146_PAGE_A2_OUT 0xc0 | ||
75 | #define SAA7146_RPS_PAGE0 0xc4 | ||
76 | #define SAA7146_RPS_PAGE1 0xc8 | ||
77 | #define SAA7146_RPS_THRESH0 0xcc | ||
78 | #define SAA7146_RPS_THRESH1 0xd0 | ||
79 | #define SAA7146_RPS_TOV0 0xd4 | ||
80 | #define SAA7146_RPS_TOV1 0xd8 | ||
81 | #define SAA7146_IER 0xdc | ||
82 | #define SAA7146_GPIO_CTRL 0xe0 | ||
83 | #define SAA7146_EC1SSR 0xe4 | ||
84 | #define SAA7146_EC2SSR 0xe8 | ||
85 | #define SAA7146_ECT1R 0xec | ||
86 | #define SAA7146_ECT2R 0xf0 | ||
87 | #define SAA7146_ACON1 0xf4 | ||
88 | #define SAA7146_ACON2 0xf8 | ||
89 | #define SAA7146_MC1 0xfc | ||
90 | #define SAA7146_MC2 0x100 | ||
91 | #define SAA7146_RPS_ADDR0 0x104 | ||
92 | #define SAA7146_RPS_ADDR1 0x108 | ||
93 | #define SAA7146_ISR 0x10c | ||
94 | #define SAA7146_PSR 0x110 | ||
95 | #define SAA7146_SSR 0x114 | ||
96 | #define SAA7146_EC1R 0x118 | ||
97 | #define SAA7146_EC2R 0x11c | ||
98 | #define SAA7146_VDP1 0x120 | ||
99 | #define SAA7146_VDP2 0x124 | ||
100 | #define SAA7146_VDP3 0x128 | ||
101 | #define SAA7146_ADP1 0x12c | ||
102 | #define SAA7146_ADP2 0x130 | ||
103 | #define SAA7146_ADP3 0x134 | ||
104 | #define SAA7146_ADP4 0x138 | ||
105 | #define SAA7146_DDP 0x13c | ||
106 | #define SAA7146_LEVEL_REP 0x140 | ||
107 | #define SAA7146_FB_BUFFER1 0x144 | ||
108 | #define SAA7146_FB_BUFFER2 0x148 | ||
109 | #define SAA7146_A_TIME_SLOT1 0x180 | ||
110 | #define SAA7146_A_TIME_SLOT2 0x1C0 | ||
111 | |||
112 | /* bitfield defines */ | ||
113 | #define MASK_31 0x80000000 | ||
114 | #define MASK_30 0x40000000 | ||
115 | #define MASK_29 0x20000000 | ||
116 | #define MASK_28 0x10000000 | ||
117 | #define MASK_27 0x08000000 | ||
118 | #define MASK_26 0x04000000 | ||
119 | #define MASK_25 0x02000000 | ||
120 | #define MASK_24 0x01000000 | ||
121 | #define MASK_23 0x00800000 | ||
122 | #define MASK_22 0x00400000 | ||
123 | #define MASK_21 0x00200000 | ||
124 | #define MASK_20 0x00100000 | ||
125 | #define MASK_19 0x00080000 | ||
126 | #define MASK_18 0x00040000 | ||
127 | #define MASK_17 0x00020000 | ||
128 | #define MASK_16 0x00010000 | ||
129 | #define MASK_15 0x00008000 | ||
130 | #define MASK_14 0x00004000 | ||
131 | #define MASK_13 0x00002000 | ||
132 | #define MASK_12 0x00001000 | ||
133 | #define MASK_11 0x00000800 | ||
134 | #define MASK_10 0x00000400 | ||
135 | #define MASK_09 0x00000200 | ||
136 | #define MASK_08 0x00000100 | ||
137 | #define MASK_07 0x00000080 | ||
138 | #define MASK_06 0x00000040 | ||
139 | #define MASK_05 0x00000020 | ||
140 | #define MASK_04 0x00000010 | ||
141 | #define MASK_03 0x00000008 | ||
142 | #define MASK_02 0x00000004 | ||
143 | #define MASK_01 0x00000002 | ||
144 | #define MASK_00 0x00000001 | ||
145 | #define MASK_B0 0x000000ff | ||
146 | #define MASK_B1 0x0000ff00 | ||
147 | #define MASK_B2 0x00ff0000 | ||
148 | #define MASK_B3 0xff000000 | ||
149 | #define MASK_W0 0x0000ffff | ||
150 | #define MASK_W1 0xffff0000 | ||
151 | #define MASK_PA 0xfffffffc | ||
152 | #define MASK_PR 0xfffffffe | ||
153 | #define MASK_ER 0xffffffff | ||
154 | #define MASK_NONE 0x00000000 | ||
155 | |||
156 | #define SAA7146_PAGE_MAP_EN MASK_11 | ||
157 | /* main control register 1 */ | ||
158 | #define SAA7146_MC1_MRST_N MASK_15 | ||
159 | #define SAA7146_MC1_ERPS1 MASK_13 | ||
160 | #define SAA7146_MC1_ERPS0 MASK_12 | ||
161 | #define SAA7146_MC1_EDP MASK_11 | ||
162 | #define SAA7146_MC1_EVP MASK_10 | ||
163 | #define SAA7146_MC1_EAP MASK_09 | ||
164 | #define SAA7146_MC1_EI2C MASK_08 | ||
165 | #define SAA7146_MC1_TR_E_DEBI MASK_07 | ||
166 | #define SAA7146_MC1_TR_E_1 MASK_06 | ||
167 | #define SAA7146_MC1_TR_E_2 MASK_05 | ||
168 | #define SAA7146_MC1_TR_E_3 MASK_04 | ||
169 | #define SAA7146_MC1_TR_E_A2_OUT MASK_03 | ||
170 | #define SAA7146_MC1_TR_E_A2_IN MASK_02 | ||
171 | #define SAA7146_MC1_TR_E_A1_OUT MASK_01 | ||
172 | #define SAA7146_MC1_TR_E_A1_IN MASK_00 | ||
173 | /* main control register 2 */ | ||
174 | #define SAA7146_MC2_RPS_SIG4 MASK_15 | ||
175 | #define SAA7146_MC2_RPS_SIG3 MASK_14 | ||
176 | #define SAA7146_MC2_RPS_SIG2 MASK_13 | ||
177 | #define SAA7146_MC2_RPS_SIG1 MASK_12 | ||
178 | #define SAA7146_MC2_RPS_SIG0 MASK_11 | ||
179 | #define SAA7146_MC2_UPLD_D1_B MASK_10 | ||
180 | #define SAA7146_MC2_UPLD_D1_A MASK_09 | ||
181 | #define SAA7146_MC2_UPLD_BRS MASK_08 | ||
182 | #define SAA7146_MC2_UPLD_HPS_H MASK_06 | ||
183 | #define SAA7146_MC2_UPLD_HPS_V MASK_05 | ||
184 | #define SAA7146_MC2_UPLD_DMA3 MASK_04 | ||
185 | #define SAA7146_MC2_UPLD_DMA2 MASK_03 | ||
186 | #define SAA7146_MC2_UPLD_DMA1 MASK_02 | ||
187 | #define SAA7146_MC2_UPLD_DEBI MASK_01 | ||
188 | #define SAA7146_MC2_UPLD_I2C MASK_00 | ||
189 | /* Primary Status Register and Interrupt Enable/Status Registers */ | ||
190 | #define SAA7146_PSR_PPEF MASK_31 | ||
191 | #define SAA7146_PSR_PABO MASK_30 | ||
192 | #define SAA7146_PSR_PPED MASK_29 | ||
193 | #define SAA7146_PSR_RPS_I1 MASK_28 | ||
194 | #define SAA7146_PSR_RPS_I0 MASK_27 | ||
195 | #define SAA7146_PSR_RPS_LATE1 MASK_26 | ||
196 | #define SAA7146_PSR_RPS_LATE0 MASK_25 | ||
197 | #define SAA7146_PSR_RPS_E1 MASK_24 | ||
198 | #define SAA7146_PSR_RPS_E0 MASK_23 | ||
199 | #define SAA7146_PSR_RPS_TO1 MASK_22 | ||
200 | #define SAA7146_PSR_RPS_TO0 MASK_21 | ||
201 | #define SAA7146_PSR_UPLD MASK_20 | ||
202 | #define SAA7146_PSR_DEBI_S MASK_19 | ||
203 | #define SAA7146_PSR_DEBI_E MASK_18 | ||
204 | #define SAA7146_PSR_I2C_S MASK_17 | ||
205 | #define SAA7146_PSR_I2C_E MASK_16 | ||
206 | #define SAA7146_PSR_A2_IN MASK_15 | ||
207 | #define SAA7146_PSR_A2_OUT MASK_14 | ||
208 | #define SAA7146_PSR_A1_IN MASK_13 | ||
209 | #define SAA7146_PSR_A1_OUT MASK_12 | ||
210 | #define SAA7146_PSR_AFOU MASK_11 | ||
211 | #define SAA7146_PSR_V_PE MASK_10 | ||
212 | #define SAA7146_PSR_VFOU MASK_09 | ||
213 | #define SAA7146_PSR_FIDA MASK_08 | ||
214 | #define SAA7146_PSR_FIDB MASK_07 | ||
215 | #define SAA7146_PSR_PIN3 MASK_06 | ||
216 | #define SAA7146_PSR_PIN2 MASK_05 | ||
217 | #define SAA7146_PSR_PIN1 MASK_04 | ||
218 | #define SAA7146_PSR_PIN0 MASK_03 | ||
219 | #define SAA7146_PSR_ECS MASK_02 | ||
220 | #define SAA7146_PSR_EC3S MASK_01 | ||
221 | #define SAA7146_PSR_EC0S MASK_00 | ||
222 | /* Secondary Status Register */ | ||
223 | #define SAA7146_SSR_PRQ MASK_31 | ||
224 | #define SAA7146_SSR_PMA MASK_30 | ||
225 | #define SAA7146_SSR_RPS_RE1 MASK_29 | ||
226 | #define SAA7146_SSR_RPS_PE1 MASK_28 | ||
227 | #define SAA7146_SSR_RPS_A1 MASK_27 | ||
228 | #define SAA7146_SSR_RPS_RE0 MASK_26 | ||
229 | #define SAA7146_SSR_RPS_PE0 MASK_25 | ||
230 | #define SAA7146_SSR_RPS_A0 MASK_24 | ||
231 | #define SAA7146_SSR_DEBI_TO MASK_23 | ||
232 | #define SAA7146_SSR_DEBI_EF MASK_22 | ||
233 | #define SAA7146_SSR_I2C_EA MASK_21 | ||
234 | #define SAA7146_SSR_I2C_EW MASK_20 | ||
235 | #define SAA7146_SSR_I2C_ER MASK_19 | ||
236 | #define SAA7146_SSR_I2C_EL MASK_18 | ||
237 | #define SAA7146_SSR_I2C_EF MASK_17 | ||
238 | #define SAA7146_SSR_V3P MASK_16 | ||
239 | #define SAA7146_SSR_V2P MASK_15 | ||
240 | #define SAA7146_SSR_V1P MASK_14 | ||
241 | #define SAA7146_SSR_VF3 MASK_13 | ||
242 | #define SAA7146_SSR_VF2 MASK_12 | ||
243 | #define SAA7146_SSR_VF1 MASK_11 | ||
244 | #define SAA7146_SSR_AF2_IN MASK_10 | ||
245 | #define SAA7146_SSR_AF2_OUT MASK_09 | ||
246 | #define SAA7146_SSR_AF1_IN MASK_08 | ||
247 | #define SAA7146_SSR_AF1_OUT MASK_07 | ||
248 | #define SAA7146_SSR_VGT MASK_05 | ||
249 | #define SAA7146_SSR_LNQG MASK_04 | ||
250 | #define SAA7146_SSR_EC5S MASK_03 | ||
251 | #define SAA7146_SSR_EC4S MASK_02 | ||
252 | #define SAA7146_SSR_EC2S MASK_01 | ||
253 | #define SAA7146_SSR_EC1S MASK_00 | ||
254 | /* I2C status register */ | ||
255 | #define SAA7146_I2C_ABORT MASK_07 | ||
256 | #define SAA7146_I2C_SPERR MASK_06 | ||
257 | #define SAA7146_I2C_APERR MASK_05 | ||
258 | #define SAA7146_I2C_DTERR MASK_04 | ||
259 | #define SAA7146_I2C_DRERR MASK_03 | ||
260 | #define SAA7146_I2C_AL MASK_02 | ||
261 | #define SAA7146_I2C_ERR MASK_01 | ||
262 | #define SAA7146_I2C_BUSY MASK_00 | ||
263 | /* output formats */ | ||
264 | #define SAA7146_YUV422 0 | ||
265 | #define SAA7146_RGB16 0 | ||
266 | #define SAA7146_YUV444 1 | ||
267 | #define SAA7146_RGB24 1 | ||
268 | #define SAA7146_ARGB32 2 | ||
269 | #define SAA7146_YUV411 3 | ||
270 | #define SAA7146_ARGB15 3 | ||
271 | #define SAA7146_YUV2 4 | ||
272 | #define SAA7146_RGAB15 4 | ||
273 | #define SAA7146_Y8 6 | ||
274 | #define SAA7146_YUV8 7 | ||
275 | #define SAA7146_RGB8 7 | ||
276 | #define SAA7146_YUV444p 8 | ||
277 | #define SAA7146_YUV422p 9 | ||
278 | #define SAA7146_YUV420p 10 | ||
279 | #define SAA7146_YUV1620 11 | ||
280 | #define SAA7146_Y1 13 | ||
281 | #define SAA7146_Y2 14 | ||
282 | #define SAA7146_YUV1 15 | ||
283 | #endif | ||
diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c index 8a98ab68239e..c8799fdaae67 100644 --- a/drivers/media/video/saa7164/saa7164-api.c +++ b/drivers/media/video/saa7164/saa7164-api.c | |||
@@ -1367,7 +1367,6 @@ int saa7164_api_i2c_read(struct saa7164_i2c *bus, u8 addr, u32 reglen, u8 *reg, | |||
1367 | struct saa7164_dev *dev = bus->dev; | 1367 | struct saa7164_dev *dev = bus->dev; |
1368 | u16 len = 0; | 1368 | u16 len = 0; |
1369 | int unitid; | 1369 | int unitid; |
1370 | u32 regval; | ||
1371 | u8 buf[256]; | 1370 | u8 buf[256]; |
1372 | int ret; | 1371 | int ret; |
1373 | 1372 | ||
@@ -1376,19 +1375,6 @@ int saa7164_api_i2c_read(struct saa7164_i2c *bus, u8 addr, u32 reglen, u8 *reg, | |||
1376 | if (reglen > 4) | 1375 | if (reglen > 4) |
1377 | return -EIO; | 1376 | return -EIO; |
1378 | 1377 | ||
1379 | if (reglen == 1) | ||
1380 | regval = *(reg); | ||
1381 | else | ||
1382 | if (reglen == 2) | ||
1383 | regval = ((*(reg) << 8) || *(reg+1)); | ||
1384 | else | ||
1385 | if (reglen == 3) | ||
1386 | regval = ((*(reg) << 16) | (*(reg+1) << 8) | *(reg+2)); | ||
1387 | else | ||
1388 | if (reglen == 4) | ||
1389 | regval = ((*(reg) << 24) | (*(reg+1) << 16) | | ||
1390 | (*(reg+2) << 8) | *(reg+3)); | ||
1391 | |||
1392 | /* Prepare the send buffer */ | 1378 | /* Prepare the send buffer */ |
1393 | /* Bytes 00-03 source register length | 1379 | /* Bytes 00-03 source register length |
1394 | * 04-07 source bytes to read | 1380 | * 04-07 source bytes to read |
diff --git a/drivers/media/video/smiapp/Kconfig b/drivers/media/video/smiapp/Kconfig index fb99ff18be07..3149cda1d0db 100644 --- a/drivers/media/video/smiapp/Kconfig +++ b/drivers/media/video/smiapp/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config VIDEO_SMIAPP | 1 | config VIDEO_SMIAPP |
2 | tristate "SMIA++/SMIA sensor support" | 2 | tristate "SMIA++/SMIA sensor support" |
3 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAVE_CLK | 3 | depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAVE_CLK |
4 | depends on MEDIA_CAMERA_SUPPORT | ||
4 | select VIDEO_SMIAPP_PLL | 5 | select VIDEO_SMIAPP_PLL |
5 | ---help--- | 6 | ---help--- |
6 | This is a generic driver for SMIA++/SMIA camera modules. | 7 | This is a generic driver for SMIA++/SMIA camera modules. |
diff --git a/drivers/media/video/smiapp/smiapp-core.c b/drivers/media/video/smiapp/smiapp-core.c index 9cf5bda35fbe..f466a7edcb2a 100644 --- a/drivers/media/video/smiapp/smiapp-core.c +++ b/drivers/media/video/smiapp/smiapp-core.c | |||
@@ -39,9 +39,9 @@ | |||
39 | 39 | ||
40 | #include "smiapp.h" | 40 | #include "smiapp.h" |
41 | 41 | ||
42 | #define SMIAPP_ALIGN_DIM(dim, flags) \ | 42 | #define SMIAPP_ALIGN_DIM(dim, flags) \ |
43 | ((flags) & V4L2_SUBDEV_SEL_FLAG_SIZE_GE \ | 43 | ((flags) & V4L2_SEL_FLAG_GE \ |
44 | ? ALIGN((dim), 2) \ | 44 | ? ALIGN((dim), 2) \ |
45 | : (dim) & ~1) | 45 | : (dim) & ~1) |
46 | 46 | ||
47 | /* | 47 | /* |
@@ -1631,7 +1631,7 @@ static void smiapp_propagate(struct v4l2_subdev *subdev, | |||
1631 | smiapp_get_crop_compose(subdev, fh, crops, &comp, which); | 1631 | smiapp_get_crop_compose(subdev, fh, crops, &comp, which); |
1632 | 1632 | ||
1633 | switch (target) { | 1633 | switch (target) { |
1634 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 1634 | case V4L2_SEL_TGT_CROP: |
1635 | comp->width = crops[SMIAPP_PAD_SINK]->width; | 1635 | comp->width = crops[SMIAPP_PAD_SINK]->width; |
1636 | comp->height = crops[SMIAPP_PAD_SINK]->height; | 1636 | comp->height = crops[SMIAPP_PAD_SINK]->height; |
1637 | if (which == V4L2_SUBDEV_FORMAT_ACTIVE) { | 1637 | if (which == V4L2_SUBDEV_FORMAT_ACTIVE) { |
@@ -1647,7 +1647,7 @@ static void smiapp_propagate(struct v4l2_subdev *subdev, | |||
1647 | } | 1647 | } |
1648 | } | 1648 | } |
1649 | /* Fall through */ | 1649 | /* Fall through */ |
1650 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL: | 1650 | case V4L2_SEL_TGT_COMPOSE: |
1651 | *crops[SMIAPP_PAD_SRC] = *comp; | 1651 | *crops[SMIAPP_PAD_SRC] = *comp; |
1652 | break; | 1652 | break; |
1653 | default: | 1653 | default: |
@@ -1723,7 +1723,7 @@ static int smiapp_set_format(struct v4l2_subdev *subdev, | |||
1723 | if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) | 1723 | if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) |
1724 | ssd->sink_fmt = *crops[ssd->sink_pad]; | 1724 | ssd->sink_fmt = *crops[ssd->sink_pad]; |
1725 | smiapp_propagate(subdev, fh, fmt->which, | 1725 | smiapp_propagate(subdev, fh, fmt->which, |
1726 | V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL); | 1726 | V4L2_SEL_TGT_CROP); |
1727 | 1727 | ||
1728 | mutex_unlock(&sensor->mutex); | 1728 | mutex_unlock(&sensor->mutex); |
1729 | 1729 | ||
@@ -1748,14 +1748,14 @@ static int scaling_goodness(struct v4l2_subdev *subdev, int w, int ask_w, | |||
1748 | h &= ~1; | 1748 | h &= ~1; |
1749 | ask_h &= ~1; | 1749 | ask_h &= ~1; |
1750 | 1750 | ||
1751 | if (flags & V4L2_SUBDEV_SEL_FLAG_SIZE_GE) { | 1751 | if (flags & V4L2_SEL_FLAG_GE) { |
1752 | if (w < ask_w) | 1752 | if (w < ask_w) |
1753 | val -= SCALING_GOODNESS; | 1753 | val -= SCALING_GOODNESS; |
1754 | if (h < ask_h) | 1754 | if (h < ask_h) |
1755 | val -= SCALING_GOODNESS; | 1755 | val -= SCALING_GOODNESS; |
1756 | } | 1756 | } |
1757 | 1757 | ||
1758 | if (flags & V4L2_SUBDEV_SEL_FLAG_SIZE_LE) { | 1758 | if (flags & V4L2_SEL_FLAG_LE) { |
1759 | if (w > ask_w) | 1759 | if (w > ask_w) |
1760 | val -= SCALING_GOODNESS; | 1760 | val -= SCALING_GOODNESS; |
1761 | if (h > ask_h) | 1761 | if (h > ask_h) |
@@ -1958,7 +1958,7 @@ static int smiapp_set_compose(struct v4l2_subdev *subdev, | |||
1958 | 1958 | ||
1959 | *comp = sel->r; | 1959 | *comp = sel->r; |
1960 | smiapp_propagate(subdev, fh, sel->which, | 1960 | smiapp_propagate(subdev, fh, sel->which, |
1961 | V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL); | 1961 | V4L2_SEL_TGT_COMPOSE); |
1962 | 1962 | ||
1963 | if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) | 1963 | if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) |
1964 | return smiapp_update_mode(sensor); | 1964 | return smiapp_update_mode(sensor); |
@@ -1974,8 +1974,8 @@ static int __smiapp_sel_supported(struct v4l2_subdev *subdev, | |||
1974 | 1974 | ||
1975 | /* We only implement crop in three places. */ | 1975 | /* We only implement crop in three places. */ |
1976 | switch (sel->target) { | 1976 | switch (sel->target) { |
1977 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 1977 | case V4L2_SEL_TGT_CROP: |
1978 | case V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS: | 1978 | case V4L2_SEL_TGT_CROP_BOUNDS: |
1979 | if (ssd == sensor->pixel_array | 1979 | if (ssd == sensor->pixel_array |
1980 | && sel->pad == SMIAPP_PA_PAD_SRC) | 1980 | && sel->pad == SMIAPP_PA_PAD_SRC) |
1981 | return 0; | 1981 | return 0; |
@@ -1988,8 +1988,8 @@ static int __smiapp_sel_supported(struct v4l2_subdev *subdev, | |||
1988 | == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) | 1988 | == SMIAPP_DIGITAL_CROP_CAPABILITY_INPUT_CROP) |
1989 | return 0; | 1989 | return 0; |
1990 | return -EINVAL; | 1990 | return -EINVAL; |
1991 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL: | 1991 | case V4L2_SEL_TGT_COMPOSE: |
1992 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS: | 1992 | case V4L2_SEL_TGT_COMPOSE_BOUNDS: |
1993 | if (sel->pad == ssd->source_pad) | 1993 | if (sel->pad == ssd->source_pad) |
1994 | return -EINVAL; | 1994 | return -EINVAL; |
1995 | if (ssd == sensor->binner) | 1995 | if (ssd == sensor->binner) |
@@ -2051,7 +2051,7 @@ static int smiapp_set_crop(struct v4l2_subdev *subdev, | |||
2051 | 2051 | ||
2052 | if (ssd != sensor->pixel_array && sel->pad == SMIAPP_PAD_SINK) | 2052 | if (ssd != sensor->pixel_array && sel->pad == SMIAPP_PAD_SINK) |
2053 | smiapp_propagate(subdev, fh, sel->which, | 2053 | smiapp_propagate(subdev, fh, sel->which, |
2054 | V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL); | 2054 | V4L2_SEL_TGT_CROP); |
2055 | 2055 | ||
2056 | return 0; | 2056 | return 0; |
2057 | } | 2057 | } |
@@ -2085,7 +2085,7 @@ static int __smiapp_get_selection(struct v4l2_subdev *subdev, | |||
2085 | } | 2085 | } |
2086 | 2086 | ||
2087 | switch (sel->target) { | 2087 | switch (sel->target) { |
2088 | case V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS: | 2088 | case V4L2_SEL_TGT_CROP_BOUNDS: |
2089 | if (ssd == sensor->pixel_array) { | 2089 | if (ssd == sensor->pixel_array) { |
2090 | sel->r.width = | 2090 | sel->r.width = |
2091 | sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; | 2091 | sensor->limits[SMIAPP_LIMIT_X_ADDR_MAX] + 1; |
@@ -2097,11 +2097,11 @@ static int __smiapp_get_selection(struct v4l2_subdev *subdev, | |||
2097 | sel->r = *comp; | 2097 | sel->r = *comp; |
2098 | } | 2098 | } |
2099 | break; | 2099 | break; |
2100 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 2100 | case V4L2_SEL_TGT_CROP: |
2101 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS: | 2101 | case V4L2_SEL_TGT_COMPOSE_BOUNDS: |
2102 | sel->r = *crops[sel->pad]; | 2102 | sel->r = *crops[sel->pad]; |
2103 | break; | 2103 | break; |
2104 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL: | 2104 | case V4L2_SEL_TGT_COMPOSE: |
2105 | sel->r = *comp; | 2105 | sel->r = *comp; |
2106 | break; | 2106 | break; |
2107 | } | 2107 | } |
@@ -2148,10 +2148,10 @@ static int smiapp_set_selection(struct v4l2_subdev *subdev, | |||
2148 | sel->r.height); | 2148 | sel->r.height); |
2149 | 2149 | ||
2150 | switch (sel->target) { | 2150 | switch (sel->target) { |
2151 | case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL: | 2151 | case V4L2_SEL_TGT_CROP: |
2152 | ret = smiapp_set_crop(subdev, fh, sel); | 2152 | ret = smiapp_set_crop(subdev, fh, sel); |
2153 | break; | 2153 | break; |
2154 | case V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL: | 2154 | case V4L2_SEL_TGT_COMPOSE: |
2155 | ret = smiapp_set_compose(subdev, fh, sel); | 2155 | ret = smiapp_set_compose(subdev, fh, sel); |
2156 | break; | 2156 | break; |
2157 | default: | 2157 | default: |
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h index 22ea211ab54f..2bc153e869be 100644 --- a/drivers/media/video/sn9c102/sn9c102.h +++ b/drivers/media/video/sn9c102/sn9c102.h | |||
@@ -182,7 +182,7 @@ do { \ | |||
182 | # define V4LDBG(level, name, cmd) \ | 182 | # define V4LDBG(level, name, cmd) \ |
183 | do { \ | 183 | do { \ |
184 | if (debug >= (level)) \ | 184 | if (debug >= (level)) \ |
185 | v4l_print_ioctl(name, cmd); \ | 185 | v4l_printk_ioctl(name, cmd); \ |
186 | } while (0) | 186 | } while (0) |
187 | # define KDBG(level, fmt, args...) \ | 187 | # define KDBG(level, fmt, args...) \ |
188 | do { \ | 188 | do { \ |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 1ad5ab6ce5cf..b5a819af2b8c 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -228,6 +228,16 @@ static int fe_has_signal(struct dvb_frontend *fe) | |||
228 | return strength; | 228 | return strength; |
229 | } | 229 | } |
230 | 230 | ||
231 | static int fe_get_afc(struct dvb_frontend *fe) | ||
232 | { | ||
233 | s32 afc = 0; | ||
234 | |||
235 | if (fe->ops.tuner_ops.get_afc) | ||
236 | fe->ops.tuner_ops.get_afc(fe, &afc); | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
231 | static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg) | 241 | static int fe_set_config(struct dvb_frontend *fe, void *priv_cfg) |
232 | { | 242 | { |
233 | struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; | 243 | struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; |
@@ -247,6 +257,7 @@ static struct analog_demod_ops tuner_analog_ops = { | |||
247 | .set_params = fe_set_params, | 257 | .set_params = fe_set_params, |
248 | .standby = fe_standby, | 258 | .standby = fe_standby, |
249 | .has_signal = fe_has_signal, | 259 | .has_signal = fe_has_signal, |
260 | .get_afc = fe_get_afc, | ||
250 | .set_config = fe_set_config, | 261 | .set_config = fe_set_config, |
251 | .tuner_status = tuner_status | 262 | .tuner_status = tuner_status |
252 | }; | 263 | }; |
@@ -1178,6 +1189,8 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
1178 | return 0; | 1189 | return 0; |
1179 | if (vt->type == t->mode && analog_ops->get_afc) | 1190 | if (vt->type == t->mode && analog_ops->get_afc) |
1180 | vt->afc = analog_ops->get_afc(&t->fe); | 1191 | vt->afc = analog_ops->get_afc(&t->fe); |
1192 | if (analog_ops->has_signal) | ||
1193 | vt->signal = analog_ops->has_signal(&t->fe); | ||
1181 | if (vt->type != V4L2_TUNER_RADIO) { | 1194 | if (vt->type != V4L2_TUNER_RADIO) { |
1182 | vt->capability |= V4L2_TUNER_CAP_NORM; | 1195 | vt->capability |= V4L2_TUNER_CAP_NORM; |
1183 | vt->rangelow = tv_range[0] * 16; | 1196 | vt->rangelow = tv_range[0] * 16; |
@@ -1197,8 +1210,6 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
1197 | V4L2_TUNER_SUB_STEREO : | 1210 | V4L2_TUNER_SUB_STEREO : |
1198 | V4L2_TUNER_SUB_MONO; | 1211 | V4L2_TUNER_SUB_MONO; |
1199 | } | 1212 | } |
1200 | if (analog_ops->has_signal) | ||
1201 | vt->signal = analog_ops->has_signal(&t->fe); | ||
1202 | vt->audmode = t->audmode; | 1213 | vt->audmode = t->audmode; |
1203 | } | 1214 | } |
1204 | vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | 1215 | vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; |
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index c5b1a7365e4f..321b3153df87 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -59,8 +59,8 @@ struct CHIPSTATE; | |||
59 | typedef int (*getvalue)(int); | 59 | typedef int (*getvalue)(int); |
60 | typedef int (*checkit)(struct CHIPSTATE*); | 60 | typedef int (*checkit)(struct CHIPSTATE*); |
61 | typedef int (*initialize)(struct CHIPSTATE*); | 61 | typedef int (*initialize)(struct CHIPSTATE*); |
62 | typedef int (*getmode)(struct CHIPSTATE*); | 62 | typedef int (*getrxsubchans)(struct CHIPSTATE *); |
63 | typedef void (*setmode)(struct CHIPSTATE*, int mode); | 63 | typedef void (*setaudmode)(struct CHIPSTATE*, int mode); |
64 | 64 | ||
65 | /* i2c command */ | 65 | /* i2c command */ |
66 | typedef struct AUDIOCMD { | 66 | typedef struct AUDIOCMD { |
@@ -96,8 +96,8 @@ struct CHIPDESC { | |||
96 | getvalue volfunc,treblefunc,bassfunc; | 96 | getvalue volfunc,treblefunc,bassfunc; |
97 | 97 | ||
98 | /* get/set mode */ | 98 | /* get/set mode */ |
99 | getmode getmode; | 99 | getrxsubchans getrxsubchans; |
100 | setmode setmode; | 100 | setaudmode setaudmode; |
101 | 101 | ||
102 | /* input switch register + values for v4l inputs */ | 102 | /* input switch register + values for v4l inputs */ |
103 | int inputreg; | 103 | int inputreg; |
@@ -118,7 +118,7 @@ struct CHIPSTATE { | |||
118 | audiocmd shadow; | 118 | audiocmd shadow; |
119 | 119 | ||
120 | /* current settings */ | 120 | /* current settings */ |
121 | __u16 left,right,treble,bass,muted,mode; | 121 | __u16 left, right, treble, bass, muted; |
122 | int prevmode; | 122 | int prevmode; |
123 | int radio; | 123 | int radio; |
124 | int input; | 124 | int input; |
@@ -126,7 +126,6 @@ struct CHIPSTATE { | |||
126 | /* thread */ | 126 | /* thread */ |
127 | struct task_struct *thread; | 127 | struct task_struct *thread; |
128 | struct timer_list wt; | 128 | struct timer_list wt; |
129 | int watch_stereo; | ||
130 | int audmode; | 129 | int audmode; |
131 | }; | 130 | }; |
132 | 131 | ||
@@ -288,7 +287,7 @@ static int chip_thread(void *data) | |||
288 | struct CHIPSTATE *chip = data; | 287 | struct CHIPSTATE *chip = data; |
289 | struct CHIPDESC *desc = chip->desc; | 288 | struct CHIPDESC *desc = chip->desc; |
290 | struct v4l2_subdev *sd = &chip->sd; | 289 | struct v4l2_subdev *sd = &chip->sd; |
291 | int mode; | 290 | int mode, selected; |
292 | 291 | ||
293 | v4l2_dbg(1, debug, sd, "thread started\n"); | 292 | v4l2_dbg(1, debug, sd, "thread started\n"); |
294 | set_freezable(); | 293 | set_freezable(); |
@@ -302,12 +301,12 @@ static int chip_thread(void *data) | |||
302 | break; | 301 | break; |
303 | v4l2_dbg(1, debug, sd, "thread wakeup\n"); | 302 | v4l2_dbg(1, debug, sd, "thread wakeup\n"); |
304 | 303 | ||
305 | /* don't do anything for radio or if mode != auto */ | 304 | /* don't do anything for radio */ |
306 | if (chip->radio || chip->mode != 0) | 305 | if (chip->radio) |
307 | continue; | 306 | continue; |
308 | 307 | ||
309 | /* have a look what's going on */ | 308 | /* have a look what's going on */ |
310 | mode = desc->getmode(chip); | 309 | mode = desc->getrxsubchans(chip); |
311 | if (mode == chip->prevmode) | 310 | if (mode == chip->prevmode) |
312 | continue; | 311 | continue; |
313 | 312 | ||
@@ -316,16 +315,32 @@ static int chip_thread(void *data) | |||
316 | 315 | ||
317 | chip->prevmode = mode; | 316 | chip->prevmode = mode; |
318 | 317 | ||
319 | if (mode & V4L2_TUNER_MODE_STEREO) | 318 | selected = V4L2_TUNER_MODE_MONO; |
320 | desc->setmode(chip, V4L2_TUNER_MODE_STEREO); | 319 | switch (chip->audmode) { |
321 | if (mode & V4L2_TUNER_MODE_LANG1_LANG2) | 320 | case V4L2_TUNER_MODE_MONO: |
322 | desc->setmode(chip, V4L2_TUNER_MODE_STEREO); | 321 | if (mode & V4L2_TUNER_SUB_LANG1) |
323 | else if (mode & V4L2_TUNER_MODE_LANG1) | 322 | selected = V4L2_TUNER_MODE_LANG1; |
324 | desc->setmode(chip, V4L2_TUNER_MODE_LANG1); | 323 | break; |
325 | else if (mode & V4L2_TUNER_MODE_LANG2) | 324 | case V4L2_TUNER_MODE_STEREO: |
326 | desc->setmode(chip, V4L2_TUNER_MODE_LANG2); | 325 | case V4L2_TUNER_MODE_LANG1: |
327 | else | 326 | if (mode & V4L2_TUNER_SUB_LANG1) |
328 | desc->setmode(chip, V4L2_TUNER_MODE_MONO); | 327 | selected = V4L2_TUNER_MODE_LANG1; |
328 | else if (mode & V4L2_TUNER_SUB_STEREO) | ||
329 | selected = V4L2_TUNER_MODE_STEREO; | ||
330 | break; | ||
331 | case V4L2_TUNER_MODE_LANG2: | ||
332 | if (mode & V4L2_TUNER_SUB_LANG2) | ||
333 | selected = V4L2_TUNER_MODE_LANG2; | ||
334 | else if (mode & V4L2_TUNER_SUB_STEREO) | ||
335 | selected = V4L2_TUNER_MODE_STEREO; | ||
336 | break; | ||
337 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
338 | if (mode & V4L2_TUNER_SUB_LANG2) | ||
339 | selected = V4L2_TUNER_MODE_LANG1_LANG2; | ||
340 | else if (mode & V4L2_TUNER_SUB_STEREO) | ||
341 | selected = V4L2_TUNER_MODE_STEREO; | ||
342 | } | ||
343 | desc->setaudmode(chip, selected); | ||
329 | 344 | ||
330 | /* schedule next check */ | 345 | /* schedule next check */ |
331 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); | 346 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); |
@@ -358,24 +373,25 @@ static int chip_thread(void *data) | |||
358 | #define TDA9840_TEST_INT1SN 0x1 /* Integration time 0.5s when set */ | 373 | #define TDA9840_TEST_INT1SN 0x1 /* Integration time 0.5s when set */ |
359 | #define TDA9840_TEST_INTFU 0x02 /* Disables integrator function */ | 374 | #define TDA9840_TEST_INTFU 0x02 /* Disables integrator function */ |
360 | 375 | ||
361 | static int tda9840_getmode(struct CHIPSTATE *chip) | 376 | static int tda9840_getrxsubchans(struct CHIPSTATE *chip) |
362 | { | 377 | { |
363 | struct v4l2_subdev *sd = &chip->sd; | 378 | struct v4l2_subdev *sd = &chip->sd; |
364 | int val, mode; | 379 | int val, mode; |
365 | 380 | ||
366 | val = chip_read(chip); | 381 | val = chip_read(chip); |
367 | mode = V4L2_TUNER_MODE_MONO; | 382 | mode = V4L2_TUNER_SUB_MONO; |
368 | if (val & TDA9840_DS_DUAL) | 383 | if (val & TDA9840_DS_DUAL) |
369 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | 384 | mode |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; |
370 | if (val & TDA9840_ST_STEREO) | 385 | if (val & TDA9840_ST_STEREO) |
371 | mode |= V4L2_TUNER_MODE_STEREO; | 386 | mode = V4L2_TUNER_SUB_STEREO; |
372 | 387 | ||
373 | v4l2_dbg(1, debug, sd, "tda9840_getmode(): raw chip read: %d, return: %d\n", | 388 | v4l2_dbg(1, debug, sd, |
389 | "tda9840_getrxsubchans(): raw chip read: %d, return: %d\n", | ||
374 | val, mode); | 390 | val, mode); |
375 | return mode; | 391 | return mode; |
376 | } | 392 | } |
377 | 393 | ||
378 | static void tda9840_setmode(struct CHIPSTATE *chip, int mode) | 394 | static void tda9840_setaudmode(struct CHIPSTATE *chip, int mode) |
379 | { | 395 | { |
380 | int update = 1; | 396 | int update = 1; |
381 | int t = chip->shadow.bytes[TDA9840_SW + 1] & ~0x7e; | 397 | int t = chip->shadow.bytes[TDA9840_SW + 1] & ~0x7e; |
@@ -393,6 +409,9 @@ static void tda9840_setmode(struct CHIPSTATE *chip, int mode) | |||
393 | case V4L2_TUNER_MODE_LANG2: | 409 | case V4L2_TUNER_MODE_LANG2: |
394 | t |= TDA9840_DUALB; | 410 | t |= TDA9840_DUALB; |
395 | break; | 411 | break; |
412 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
413 | t |= TDA9840_DUALAB; | ||
414 | break; | ||
396 | default: | 415 | default: |
397 | update = 0; | 416 | update = 0; |
398 | } | 417 | } |
@@ -477,6 +496,7 @@ static int tda9840_checkit(struct CHIPSTATE *chip) | |||
477 | /* 0x06 - C6 - Control 2 in TDA9855, Control 3 in TDA9850 */ | 496 | /* 0x06 - C6 - Control 2 in TDA9855, Control 3 in TDA9850 */ |
478 | /* Common to TDA9855 and TDA9850: */ | 497 | /* Common to TDA9855 and TDA9850: */ |
479 | #define TDA985x_SAP 3<<6 /* Selects SAP output, mute if not received */ | 498 | #define TDA985x_SAP 3<<6 /* Selects SAP output, mute if not received */ |
499 | #define TDA985x_MONOSAP 2<<6 /* Selects Mono on left, SAP on right */ | ||
480 | #define TDA985x_STEREO 1<<6 /* Selects Stereo ouput, mono if not received */ | 500 | #define TDA985x_STEREO 1<<6 /* Selects Stereo ouput, mono if not received */ |
481 | #define TDA985x_MONO 0 /* Forces Mono output */ | 501 | #define TDA985x_MONO 0 /* Forces Mono output */ |
482 | #define TDA985x_LMU 1<<3 /* Mute (LOR/LOL for 9855, OUTL/OUTR for 9850) */ | 502 | #define TDA985x_LMU 1<<3 /* Mute (LOR/LOL for 9855, OUTL/OUTR for 9850) */ |
@@ -513,18 +533,22 @@ static int tda9855_volume(int val) { return val/0x2e8+0x27; } | |||
513 | static int tda9855_bass(int val) { return val/0xccc+0x06; } | 533 | static int tda9855_bass(int val) { return val/0xccc+0x06; } |
514 | static int tda9855_treble(int val) { return (val/0x1c71+0x3)<<1; } | 534 | static int tda9855_treble(int val) { return (val/0x1c71+0x3)<<1; } |
515 | 535 | ||
516 | static int tda985x_getmode(struct CHIPSTATE *chip) | 536 | static int tda985x_getrxsubchans(struct CHIPSTATE *chip) |
517 | { | 537 | { |
518 | int mode; | 538 | int mode, val; |
519 | 539 | ||
520 | mode = ((TDA985x_STP | TDA985x_SAPP) & | ||
521 | chip_read(chip)) >> 4; | ||
522 | /* Add mono mode regardless of SAP and stereo */ | 540 | /* Add mono mode regardless of SAP and stereo */ |
523 | /* Allows forced mono */ | 541 | /* Allows forced mono */ |
524 | return mode | V4L2_TUNER_MODE_MONO; | 542 | mode = V4L2_TUNER_SUB_MONO; |
543 | val = chip_read(chip); | ||
544 | if (val & TDA985x_STP) | ||
545 | mode = V4L2_TUNER_SUB_STEREO; | ||
546 | if (val & TDA985x_SAPP) | ||
547 | mode |= V4L2_TUNER_SUB_SAP; | ||
548 | return mode; | ||
525 | } | 549 | } |
526 | 550 | ||
527 | static void tda985x_setmode(struct CHIPSTATE *chip, int mode) | 551 | static void tda985x_setaudmode(struct CHIPSTATE *chip, int mode) |
528 | { | 552 | { |
529 | int update = 1; | 553 | int update = 1; |
530 | int c6 = chip->shadow.bytes[TDA985x_C6+1] & 0x3f; | 554 | int c6 = chip->shadow.bytes[TDA985x_C6+1] & 0x3f; |
@@ -534,11 +558,15 @@ static void tda985x_setmode(struct CHIPSTATE *chip, int mode) | |||
534 | c6 |= TDA985x_MONO; | 558 | c6 |= TDA985x_MONO; |
535 | break; | 559 | break; |
536 | case V4L2_TUNER_MODE_STEREO: | 560 | case V4L2_TUNER_MODE_STEREO: |
561 | case V4L2_TUNER_MODE_LANG1: | ||
537 | c6 |= TDA985x_STEREO; | 562 | c6 |= TDA985x_STEREO; |
538 | break; | 563 | break; |
539 | case V4L2_TUNER_MODE_LANG1: | 564 | case V4L2_TUNER_MODE_SAP: |
540 | c6 |= TDA985x_SAP; | 565 | c6 |= TDA985x_SAP; |
541 | break; | 566 | break; |
567 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
568 | c6 |= TDA985x_MONOSAP; | ||
569 | break; | ||
542 | default: | 570 | default: |
543 | update = 0; | 571 | update = 0; |
544 | } | 572 | } |
@@ -583,9 +611,10 @@ static void tda985x_setmode(struct CHIPSTATE *chip, int mode) | |||
583 | #define TDA9873_TR_MASK (7 << 2) | 611 | #define TDA9873_TR_MASK (7 << 2) |
584 | #define TDA9873_TR_MONO 4 | 612 | #define TDA9873_TR_MONO 4 |
585 | #define TDA9873_TR_STEREO 1 << 4 | 613 | #define TDA9873_TR_STEREO 1 << 4 |
586 | #define TDA9873_TR_REVERSE (1 << 3) & (1 << 2) | 614 | #define TDA9873_TR_REVERSE ((1 << 3) | (1 << 2)) |
587 | #define TDA9873_TR_DUALA 1 << 2 | 615 | #define TDA9873_TR_DUALA 1 << 2 |
588 | #define TDA9873_TR_DUALB 1 << 3 | 616 | #define TDA9873_TR_DUALB 1 << 3 |
617 | #define TDA9873_TR_DUALAB 0 | ||
589 | 618 | ||
590 | /* output level controls | 619 | /* output level controls |
591 | * B5: output level switch (0 = reduced gain, 1 = normal gain) | 620 | * B5: output level switch (0 = reduced gain, 1 = normal gain) |
@@ -653,46 +682,51 @@ static void tda985x_setmode(struct CHIPSTATE *chip, int mode) | |||
653 | #define TDA9873_MOUT_DUALA 0 | 682 | #define TDA9873_MOUT_DUALA 0 |
654 | #define TDA9873_MOUT_DUALB 1 << 3 | 683 | #define TDA9873_MOUT_DUALB 1 << 3 |
655 | #define TDA9873_MOUT_ST 1 << 4 | 684 | #define TDA9873_MOUT_ST 1 << 4 |
656 | #define TDA9873_MOUT_EXTM (1 << 4 ) & (1 << 3) | 685 | #define TDA9873_MOUT_EXTM ((1 << 4) | (1 << 3)) |
657 | #define TDA9873_MOUT_EXTL 1 << 5 | 686 | #define TDA9873_MOUT_EXTL 1 << 5 |
658 | #define TDA9873_MOUT_EXTR (1 << 5 ) & (1 << 3) | 687 | #define TDA9873_MOUT_EXTR ((1 << 5) | (1 << 3)) |
659 | #define TDA9873_MOUT_EXTLR (1 << 5 ) & (1 << 4) | 688 | #define TDA9873_MOUT_EXTLR ((1 << 5) | (1 << 4)) |
660 | #define TDA9873_MOUT_MUTE (1 << 5 ) & (1 << 4) & (1 << 3) | 689 | #define TDA9873_MOUT_MUTE ((1 << 5) | (1 << 4) | (1 << 3)) |
661 | 690 | ||
662 | /* Status bits: (chip read) */ | 691 | /* Status bits: (chip read) */ |
663 | #define TDA9873_PONR 0 /* Power-on reset detected if = 1 */ | 692 | #define TDA9873_PONR 0 /* Power-on reset detected if = 1 */ |
664 | #define TDA9873_STEREO 2 /* Stereo sound is identified */ | 693 | #define TDA9873_STEREO 2 /* Stereo sound is identified */ |
665 | #define TDA9873_DUAL 4 /* Dual sound is identified */ | 694 | #define TDA9873_DUAL 4 /* Dual sound is identified */ |
666 | 695 | ||
667 | static int tda9873_getmode(struct CHIPSTATE *chip) | 696 | static int tda9873_getrxsubchans(struct CHIPSTATE *chip) |
668 | { | 697 | { |
669 | struct v4l2_subdev *sd = &chip->sd; | 698 | struct v4l2_subdev *sd = &chip->sd; |
670 | int val,mode; | 699 | int val,mode; |
671 | 700 | ||
672 | val = chip_read(chip); | 701 | val = chip_read(chip); |
673 | mode = V4L2_TUNER_MODE_MONO; | 702 | mode = V4L2_TUNER_SUB_MONO; |
674 | if (val & TDA9873_STEREO) | 703 | if (val & TDA9873_STEREO) |
675 | mode |= V4L2_TUNER_MODE_STEREO; | 704 | mode = V4L2_TUNER_SUB_STEREO; |
676 | if (val & TDA9873_DUAL) | 705 | if (val & TDA9873_DUAL) |
677 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | 706 | mode |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; |
678 | v4l2_dbg(1, debug, sd, "tda9873_getmode(): raw chip read: %d, return: %d\n", | 707 | v4l2_dbg(1, debug, sd, |
708 | "tda9873_getrxsubchans(): raw chip read: %d, return: %d\n", | ||
679 | val, mode); | 709 | val, mode); |
680 | return mode; | 710 | return mode; |
681 | } | 711 | } |
682 | 712 | ||
683 | static void tda9873_setmode(struct CHIPSTATE *chip, int mode) | 713 | static void tda9873_setaudmode(struct CHIPSTATE *chip, int mode) |
684 | { | 714 | { |
685 | struct v4l2_subdev *sd = &chip->sd; | 715 | struct v4l2_subdev *sd = &chip->sd; |
686 | int sw_data = chip->shadow.bytes[TDA9873_SW+1] & ~ TDA9873_TR_MASK; | 716 | int sw_data = chip->shadow.bytes[TDA9873_SW+1] & ~ TDA9873_TR_MASK; |
687 | /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ | 717 | /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ |
688 | 718 | ||
689 | if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { | 719 | if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { |
690 | v4l2_dbg(1, debug, sd, "tda9873_setmode(): external input\n"); | 720 | v4l2_dbg(1, debug, sd, |
721 | "tda9873_setaudmode(): external input\n"); | ||
691 | return; | 722 | return; |
692 | } | 723 | } |
693 | 724 | ||
694 | v4l2_dbg(1, debug, sd, "tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); | 725 | v4l2_dbg(1, debug, sd, |
695 | v4l2_dbg(1, debug, sd, "tda9873_setmode(): sw_data = %d\n", sw_data); | 726 | "tda9873_setaudmode(): chip->shadow.bytes[%d] = %d\n", |
727 | TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); | ||
728 | v4l2_dbg(1, debug, sd, "tda9873_setaudmode(): sw_data = %d\n", | ||
729 | sw_data); | ||
696 | 730 | ||
697 | switch (mode) { | 731 | switch (mode) { |
698 | case V4L2_TUNER_MODE_MONO: | 732 | case V4L2_TUNER_MODE_MONO: |
@@ -707,13 +741,16 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) | |||
707 | case V4L2_TUNER_MODE_LANG2: | 741 | case V4L2_TUNER_MODE_LANG2: |
708 | sw_data |= TDA9873_TR_DUALB; | 742 | sw_data |= TDA9873_TR_DUALB; |
709 | break; | 743 | break; |
744 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
745 | sw_data |= TDA9873_TR_DUALAB; | ||
746 | break; | ||
710 | default: | 747 | default: |
711 | chip->mode = 0; | ||
712 | return; | 748 | return; |
713 | } | 749 | } |
714 | 750 | ||
715 | chip_write(chip, TDA9873_SW, sw_data); | 751 | chip_write(chip, TDA9873_SW, sw_data); |
716 | v4l2_dbg(1, debug, sd, "tda9873_setmode(): req. mode %d; chip_write: %d\n", | 752 | v4l2_dbg(1, debug, sd, |
753 | "tda9873_setaudmode(): req. mode %d; chip_write: %d\n", | ||
717 | mode, sw_data); | 754 | mode, sw_data); |
718 | } | 755 | } |
719 | 756 | ||
@@ -859,13 +896,13 @@ static int tda9874a_setup(struct CHIPSTATE *chip) | |||
859 | return 1; | 896 | return 1; |
860 | } | 897 | } |
861 | 898 | ||
862 | static int tda9874a_getmode(struct CHIPSTATE *chip) | 899 | static int tda9874a_getrxsubchans(struct CHIPSTATE *chip) |
863 | { | 900 | { |
864 | struct v4l2_subdev *sd = &chip->sd; | 901 | struct v4l2_subdev *sd = &chip->sd; |
865 | int dsr,nsr,mode; | 902 | int dsr,nsr,mode; |
866 | int necr; /* just for debugging */ | 903 | int necr; /* just for debugging */ |
867 | 904 | ||
868 | mode = V4L2_TUNER_MODE_MONO; | 905 | mode = V4L2_TUNER_SUB_MONO; |
869 | 906 | ||
870 | if(-1 == (dsr = chip_read2(chip,TDA9874A_DSR))) | 907 | if(-1 == (dsr = chip_read2(chip,TDA9874A_DSR))) |
871 | return mode; | 908 | return mode; |
@@ -888,22 +925,23 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) | |||
888 | * external 4052 multiplexer in audio_hook(). | 925 | * external 4052 multiplexer in audio_hook(). |
889 | */ | 926 | */ |
890 | if(nsr & 0x02) /* NSR.S/MB=1 */ | 927 | if(nsr & 0x02) /* NSR.S/MB=1 */ |
891 | mode |= V4L2_TUNER_MODE_STEREO; | 928 | mode = V4L2_TUNER_SUB_STEREO; |
892 | if(nsr & 0x01) /* NSR.D/SB=1 */ | 929 | if(nsr & 0x01) /* NSR.D/SB=1 */ |
893 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | 930 | mode |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; |
894 | } else { | 931 | } else { |
895 | if(dsr & 0x02) /* DSR.IDSTE=1 */ | 932 | if(dsr & 0x02) /* DSR.IDSTE=1 */ |
896 | mode |= V4L2_TUNER_MODE_STEREO; | 933 | mode = V4L2_TUNER_SUB_STEREO; |
897 | if(dsr & 0x04) /* DSR.IDDUA=1 */ | 934 | if(dsr & 0x04) /* DSR.IDDUA=1 */ |
898 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | 935 | mode |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; |
899 | } | 936 | } |
900 | 937 | ||
901 | v4l2_dbg(1, debug, sd, "tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", | 938 | v4l2_dbg(1, debug, sd, |
939 | "tda9874a_getrxsubchans(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", | ||
902 | dsr, nsr, necr, mode); | 940 | dsr, nsr, necr, mode); |
903 | return mode; | 941 | return mode; |
904 | } | 942 | } |
905 | 943 | ||
906 | static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | 944 | static void tda9874a_setaudmode(struct CHIPSTATE *chip, int mode) |
907 | { | 945 | { |
908 | struct v4l2_subdev *sd = &chip->sd; | 946 | struct v4l2_subdev *sd = &chip->sd; |
909 | 947 | ||
@@ -939,14 +977,18 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
939 | aosr = 0xa0; /* auto-select, dual B/B */ | 977 | aosr = 0xa0; /* auto-select, dual B/B */ |
940 | mdacosr = (tda9874a_mode) ? 0x83:0x81; | 978 | mdacosr = (tda9874a_mode) ? 0x83:0x81; |
941 | break; | 979 | break; |
980 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
981 | aosr = 0x00; /* always route L to L and R to R */ | ||
982 | mdacosr = (tda9874a_mode) ? 0x82:0x80; | ||
983 | break; | ||
942 | default: | 984 | default: |
943 | chip->mode = 0; | ||
944 | return; | 985 | return; |
945 | } | 986 | } |
946 | chip_write(chip, TDA9874A_AOSR, aosr); | 987 | chip_write(chip, TDA9874A_AOSR, aosr); |
947 | chip_write(chip, TDA9874A_MDACOSR, mdacosr); | 988 | chip_write(chip, TDA9874A_MDACOSR, mdacosr); |
948 | 989 | ||
949 | v4l2_dbg(1, debug, sd, "tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", | 990 | v4l2_dbg(1, debug, sd, |
991 | "tda9874a_setaudmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", | ||
950 | mode, aosr, mdacosr); | 992 | mode, aosr, mdacosr); |
951 | 993 | ||
952 | } else { /* dic == 0x07 */ | 994 | } else { /* dic == 0x07 */ |
@@ -974,14 +1016,18 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
974 | fmmr = 0x02; /* dual */ | 1016 | fmmr = 0x02; /* dual */ |
975 | aosr = 0x20; /* dual B/B */ | 1017 | aosr = 0x20; /* dual B/B */ |
976 | break; | 1018 | break; |
1019 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
1020 | fmmr = 0x02; /* dual */ | ||
1021 | aosr = 0x00; /* dual A/B */ | ||
1022 | break; | ||
977 | default: | 1023 | default: |
978 | chip->mode = 0; | ||
979 | return; | 1024 | return; |
980 | } | 1025 | } |
981 | chip_write(chip, TDA9874A_FMMR, fmmr); | 1026 | chip_write(chip, TDA9874A_FMMR, fmmr); |
982 | chip_write(chip, TDA9874A_AOSR, aosr); | 1027 | chip_write(chip, TDA9874A_AOSR, aosr); |
983 | 1028 | ||
984 | v4l2_dbg(1, debug, sd, "tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", | 1029 | v4l2_dbg(1, debug, sd, |
1030 | "tda9874a_setaudmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", | ||
985 | mode, fmmr, aosr); | 1031 | mode, fmmr, aosr); |
986 | } | 1032 | } |
987 | } | 1033 | } |
@@ -1226,25 +1272,33 @@ static int tea6320_initialize(struct CHIPSTATE * chip) | |||
1226 | static int tda8425_shift10(int val) { return (val >> 10) | 0xc0; } | 1272 | static int tda8425_shift10(int val) { return (val >> 10) | 0xc0; } |
1227 | static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; } | 1273 | static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; } |
1228 | 1274 | ||
1229 | static void tda8425_setmode(struct CHIPSTATE *chip, int mode) | 1275 | static void tda8425_setaudmode(struct CHIPSTATE *chip, int mode) |
1230 | { | 1276 | { |
1231 | int s1 = chip->shadow.bytes[TDA8425_S1+1] & 0xe1; | 1277 | int s1 = chip->shadow.bytes[TDA8425_S1+1] & 0xe1; |
1232 | 1278 | ||
1233 | if (mode & V4L2_TUNER_MODE_LANG1) { | 1279 | switch (mode) { |
1280 | case V4L2_TUNER_MODE_LANG1: | ||
1234 | s1 |= TDA8425_S1_ML_SOUND_A; | 1281 | s1 |= TDA8425_S1_ML_SOUND_A; |
1235 | s1 |= TDA8425_S1_STEREO_PSEUDO; | 1282 | s1 |= TDA8425_S1_STEREO_PSEUDO; |
1236 | 1283 | break; | |
1237 | } else if (mode & V4L2_TUNER_MODE_LANG2) { | 1284 | case V4L2_TUNER_MODE_LANG2: |
1238 | s1 |= TDA8425_S1_ML_SOUND_B; | 1285 | s1 |= TDA8425_S1_ML_SOUND_B; |
1239 | s1 |= TDA8425_S1_STEREO_PSEUDO; | 1286 | s1 |= TDA8425_S1_STEREO_PSEUDO; |
1240 | 1287 | break; | |
1241 | } else { | 1288 | case V4L2_TUNER_MODE_LANG1_LANG2: |
1242 | s1 |= TDA8425_S1_ML_STEREO; | 1289 | s1 |= TDA8425_S1_ML_STEREO; |
1243 | 1290 | s1 |= TDA8425_S1_STEREO_LINEAR; | |
1244 | if (mode & V4L2_TUNER_MODE_MONO) | 1291 | break; |
1245 | s1 |= TDA8425_S1_STEREO_MONO; | 1292 | case V4L2_TUNER_MODE_MONO: |
1246 | if (mode & V4L2_TUNER_MODE_STEREO) | 1293 | s1 |= TDA8425_S1_ML_STEREO; |
1247 | s1 |= TDA8425_S1_STEREO_SPATIAL; | 1294 | s1 |= TDA8425_S1_STEREO_MONO; |
1295 | break; | ||
1296 | case V4L2_TUNER_MODE_STEREO: | ||
1297 | s1 |= TDA8425_S1_ML_STEREO; | ||
1298 | s1 |= TDA8425_S1_STEREO_SPATIAL; | ||
1299 | break; | ||
1300 | default: | ||
1301 | return; | ||
1248 | } | 1302 | } |
1249 | chip_write(chip,TDA8425_S1,s1); | 1303 | chip_write(chip,TDA8425_S1,s1); |
1250 | } | 1304 | } |
@@ -1297,18 +1351,20 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) | |||
1297 | * stereo L L | 1351 | * stereo L L |
1298 | * BIL H L | 1352 | * BIL H L |
1299 | */ | 1353 | */ |
1300 | static int ta8874z_getmode(struct CHIPSTATE *chip) | 1354 | static int ta8874z_getrxsubchans(struct CHIPSTATE *chip) |
1301 | { | 1355 | { |
1302 | int val, mode; | 1356 | int val, mode; |
1303 | 1357 | ||
1304 | val = chip_read(chip); | 1358 | val = chip_read(chip); |
1305 | mode = V4L2_TUNER_MODE_MONO; | 1359 | mode = V4L2_TUNER_SUB_MONO; |
1306 | if (val & TA8874Z_B1){ | 1360 | if (val & TA8874Z_B1){ |
1307 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | 1361 | mode |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; |
1308 | }else if (!(val & TA8874Z_B0)){ | 1362 | }else if (!(val & TA8874Z_B0)){ |
1309 | mode |= V4L2_TUNER_MODE_STEREO; | 1363 | mode = V4L2_TUNER_SUB_STEREO; |
1310 | } | 1364 | } |
1311 | /* v4l_dbg(1, debug, chip->c, "ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ | 1365 | /* v4l2_dbg(1, debug, &chip->sd, |
1366 | "ta8874z_getrxsubchans(): raw chip read: 0x%02x, return: 0x%02x\n", | ||
1367 | val, mode); */ | ||
1312 | return mode; | 1368 | return mode; |
1313 | } | 1369 | } |
1314 | 1370 | ||
@@ -1316,14 +1372,15 @@ static audiocmd ta8874z_stereo = { 2, {0, TA8874Z_SEPARATION_DEFAULT}}; | |||
1316 | static audiocmd ta8874z_mono = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}; | 1372 | static audiocmd ta8874z_mono = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}; |
1317 | static audiocmd ta8874z_main = {2, { 0, TA8874Z_SEPARATION_DEFAULT}}; | 1373 | static audiocmd ta8874z_main = {2, { 0, TA8874Z_SEPARATION_DEFAULT}}; |
1318 | static audiocmd ta8874z_sub = {2, { TA8874Z_MODE_SUB, TA8874Z_SEPARATION_DEFAULT}}; | 1374 | static audiocmd ta8874z_sub = {2, { TA8874Z_MODE_SUB, TA8874Z_SEPARATION_DEFAULT}}; |
1375 | static audiocmd ta8874z_both = {2, { TA8874Z_MODE_MAIN | TA8874Z_MODE_SUB, TA8874Z_SEPARATION_DEFAULT}}; | ||
1319 | 1376 | ||
1320 | static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) | 1377 | static void ta8874z_setaudmode(struct CHIPSTATE *chip, int mode) |
1321 | { | 1378 | { |
1322 | struct v4l2_subdev *sd = &chip->sd; | 1379 | struct v4l2_subdev *sd = &chip->sd; |
1323 | int update = 1; | 1380 | int update = 1; |
1324 | audiocmd *t = NULL; | 1381 | audiocmd *t = NULL; |
1325 | 1382 | ||
1326 | v4l2_dbg(1, debug, sd, "ta8874z_setmode(): mode: 0x%02x\n", mode); | 1383 | v4l2_dbg(1, debug, sd, "ta8874z_setaudmode(): mode: 0x%02x\n", mode); |
1327 | 1384 | ||
1328 | switch(mode){ | 1385 | switch(mode){ |
1329 | case V4L2_TUNER_MODE_MONO: | 1386 | case V4L2_TUNER_MODE_MONO: |
@@ -1338,6 +1395,9 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) | |||
1338 | case V4L2_TUNER_MODE_LANG2: | 1395 | case V4L2_TUNER_MODE_LANG2: |
1339 | t = &ta8874z_sub; | 1396 | t = &ta8874z_sub; |
1340 | break; | 1397 | break; |
1398 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
1399 | t = &ta8874z_both; | ||
1400 | break; | ||
1341 | default: | 1401 | default: |
1342 | update = 0; | 1402 | update = 0; |
1343 | } | 1403 | } |
@@ -1394,8 +1454,8 @@ static struct CHIPDESC chiplist[] = { | |||
1394 | 1454 | ||
1395 | /* callbacks */ | 1455 | /* callbacks */ |
1396 | .checkit = tda9840_checkit, | 1456 | .checkit = tda9840_checkit, |
1397 | .getmode = tda9840_getmode, | 1457 | .getrxsubchans = tda9840_getrxsubchans, |
1398 | .setmode = tda9840_setmode, | 1458 | .setaudmode = tda9840_setaudmode, |
1399 | 1459 | ||
1400 | .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN | 1460 | .init = { 2, { TDA9840_TEST, TDA9840_TEST_INT1SN |
1401 | /* ,TDA9840_SW, TDA9840_MONO */} } | 1461 | /* ,TDA9840_SW, TDA9840_MONO */} } |
@@ -1410,8 +1470,8 @@ static struct CHIPDESC chiplist[] = { | |||
1410 | 1470 | ||
1411 | /* callbacks */ | 1471 | /* callbacks */ |
1412 | .checkit = tda9873_checkit, | 1472 | .checkit = tda9873_checkit, |
1413 | .getmode = tda9873_getmode, | 1473 | .getrxsubchans = tda9873_getrxsubchans, |
1414 | .setmode = tda9873_setmode, | 1474 | .setaudmode = tda9873_setaudmode, |
1415 | 1475 | ||
1416 | .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, | 1476 | .init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } }, |
1417 | .inputreg = TDA9873_SW, | 1477 | .inputreg = TDA9873_SW, |
@@ -1430,8 +1490,8 @@ static struct CHIPDESC chiplist[] = { | |||
1430 | /* callbacks */ | 1490 | /* callbacks */ |
1431 | .initialize = tda9874a_initialize, | 1491 | .initialize = tda9874a_initialize, |
1432 | .checkit = tda9874a_checkit, | 1492 | .checkit = tda9874a_checkit, |
1433 | .getmode = tda9874a_getmode, | 1493 | .getrxsubchans = tda9874a_getrxsubchans, |
1434 | .setmode = tda9874a_setmode, | 1494 | .setaudmode = tda9874a_setaudmode, |
1435 | }, | 1495 | }, |
1436 | { | 1496 | { |
1437 | .name = "tda9875", | 1497 | .name = "tda9875", |
@@ -1460,8 +1520,8 @@ static struct CHIPDESC chiplist[] = { | |||
1460 | .addr_hi = I2C_ADDR_TDA985x_H >> 1, | 1520 | .addr_hi = I2C_ADDR_TDA985x_H >> 1, |
1461 | .registers = 11, | 1521 | .registers = 11, |
1462 | 1522 | ||
1463 | .getmode = tda985x_getmode, | 1523 | .getrxsubchans = tda985x_getrxsubchans, |
1464 | .setmode = tda985x_setmode, | 1524 | .setaudmode = tda985x_setaudmode, |
1465 | 1525 | ||
1466 | .init = { 8, { TDA9850_C4, 0x08, 0x08, TDA985x_STEREO, 0x07, 0x10, 0x10, 0x03 } } | 1526 | .init = { 8, { TDA9850_C4, 0x08, 0x08, TDA985x_STEREO, 0x07, 0x10, 0x10, 0x03 } } |
1467 | }, | 1527 | }, |
@@ -1482,8 +1542,8 @@ static struct CHIPDESC chiplist[] = { | |||
1482 | .volfunc = tda9855_volume, | 1542 | .volfunc = tda9855_volume, |
1483 | .bassfunc = tda9855_bass, | 1543 | .bassfunc = tda9855_bass, |
1484 | .treblefunc = tda9855_treble, | 1544 | .treblefunc = tda9855_treble, |
1485 | .getmode = tda985x_getmode, | 1545 | .getrxsubchans = tda985x_getrxsubchans, |
1486 | .setmode = tda985x_setmode, | 1546 | .setaudmode = tda985x_setaudmode, |
1487 | 1547 | ||
1488 | .init = { 12, { 0, 0x6f, 0x6f, 0x0e, 0x07<<1, 0x8<<2, | 1548 | .init = { 12, { 0, 0x6f, 0x6f, 0x0e, 0x07<<1, 0x8<<2, |
1489 | TDA9855_MUTE | TDA9855_AVL | TDA9855_LOUD | TDA9855_INT, | 1549 | TDA9855_MUTE | TDA9855_AVL | TDA9855_LOUD | TDA9855_INT, |
@@ -1564,7 +1624,7 @@ static struct CHIPDESC chiplist[] = { | |||
1564 | .volfunc = tda8425_shift10, | 1624 | .volfunc = tda8425_shift10, |
1565 | .bassfunc = tda8425_shift12, | 1625 | .bassfunc = tda8425_shift12, |
1566 | .treblefunc = tda8425_shift12, | 1626 | .treblefunc = tda8425_shift12, |
1567 | .setmode = tda8425_setmode, | 1627 | .setaudmode = tda8425_setaudmode, |
1568 | 1628 | ||
1569 | .inputreg = TDA8425_S1, | 1629 | .inputreg = TDA8425_S1, |
1570 | .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 }, | 1630 | .inputmap = { TDA8425_S1_CH1, TDA8425_S1_CH1, TDA8425_S1_CH1 }, |
@@ -1593,11 +1653,10 @@ static struct CHIPDESC chiplist[] = { | |||
1593 | .addr_lo = I2C_ADDR_TDA9840 >> 1, | 1653 | .addr_lo = I2C_ADDR_TDA9840 >> 1, |
1594 | .addr_hi = I2C_ADDR_TDA9840 >> 1, | 1654 | .addr_hi = I2C_ADDR_TDA9840 >> 1, |
1595 | .registers = 2, | 1655 | .registers = 2, |
1596 | .flags = CHIP_NEED_CHECKMODE, | ||
1597 | 1656 | ||
1598 | /* callbacks */ | 1657 | /* callbacks */ |
1599 | .getmode = ta8874z_getmode, | 1658 | .getrxsubchans = ta8874z_getrxsubchans, |
1600 | .setmode = ta8874z_setmode, | 1659 | .setaudmode = ta8874z_setaudmode, |
1601 | 1660 | ||
1602 | .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}, | 1661 | .init = {2, { TA8874Z_MONO_SET, TA8874Z_SEPARATION_DEFAULT}}, |
1603 | }, | 1662 | }, |
@@ -1736,7 +1795,6 @@ static int tvaudio_s_radio(struct v4l2_subdev *sd) | |||
1736 | struct CHIPSTATE *chip = to_state(sd); | 1795 | struct CHIPSTATE *chip = to_state(sd); |
1737 | 1796 | ||
1738 | chip->radio = 1; | 1797 | chip->radio = 1; |
1739 | chip->watch_stereo = 0; | ||
1740 | /* del_timer(&chip->wt); */ | 1798 | /* del_timer(&chip->wt); */ |
1741 | return 0; | 1799 | return 0; |
1742 | } | 1800 | } |
@@ -1793,9 +1851,8 @@ static int tvaudio_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
1793 | { | 1851 | { |
1794 | struct CHIPSTATE *chip = to_state(sd); | 1852 | struct CHIPSTATE *chip = to_state(sd); |
1795 | struct CHIPDESC *desc = chip->desc; | 1853 | struct CHIPDESC *desc = chip->desc; |
1796 | int mode = 0; | ||
1797 | 1854 | ||
1798 | if (!desc->setmode) | 1855 | if (!desc->setaudmode) |
1799 | return 0; | 1856 | return 0; |
1800 | if (chip->radio) | 1857 | if (chip->radio) |
1801 | return 0; | 1858 | return 0; |
@@ -1805,22 +1862,18 @@ static int tvaudio_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
1805 | case V4L2_TUNER_MODE_STEREO: | 1862 | case V4L2_TUNER_MODE_STEREO: |
1806 | case V4L2_TUNER_MODE_LANG1: | 1863 | case V4L2_TUNER_MODE_LANG1: |
1807 | case V4L2_TUNER_MODE_LANG2: | 1864 | case V4L2_TUNER_MODE_LANG2: |
1808 | mode = vt->audmode; | ||
1809 | break; | ||
1810 | case V4L2_TUNER_MODE_LANG1_LANG2: | 1865 | case V4L2_TUNER_MODE_LANG1_LANG2: |
1811 | mode = V4L2_TUNER_MODE_STEREO; | ||
1812 | break; | 1866 | break; |
1813 | default: | 1867 | default: |
1814 | return -EINVAL; | 1868 | return -EINVAL; |
1815 | } | 1869 | } |
1816 | chip->audmode = vt->audmode; | 1870 | chip->audmode = vt->audmode; |
1817 | 1871 | ||
1818 | if (mode) { | 1872 | if (chip->thread) |
1819 | chip->watch_stereo = 0; | 1873 | wake_up_process(chip->thread); |
1820 | /* del_timer(&chip->wt); */ | 1874 | else |
1821 | chip->mode = mode; | 1875 | desc->setaudmode(chip, vt->audmode); |
1822 | desc->setmode(chip, mode); | 1876 | |
1823 | } | ||
1824 | return 0; | 1877 | return 0; |
1825 | } | 1878 | } |
1826 | 1879 | ||
@@ -1828,30 +1881,17 @@ static int tvaudio_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) | |||
1828 | { | 1881 | { |
1829 | struct CHIPSTATE *chip = to_state(sd); | 1882 | struct CHIPSTATE *chip = to_state(sd); |
1830 | struct CHIPDESC *desc = chip->desc; | 1883 | struct CHIPDESC *desc = chip->desc; |
1831 | int mode = V4L2_TUNER_MODE_MONO; | ||
1832 | 1884 | ||
1833 | if (!desc->getmode) | 1885 | if (!desc->getrxsubchans) |
1834 | return 0; | 1886 | return 0; |
1835 | if (chip->radio) | 1887 | if (chip->radio) |
1836 | return 0; | 1888 | return 0; |
1837 | 1889 | ||
1838 | vt->audmode = chip->audmode; | 1890 | vt->audmode = chip->audmode; |
1839 | vt->rxsubchans = 0; | 1891 | vt->rxsubchans = desc->getrxsubchans(chip); |
1840 | vt->capability = V4L2_TUNER_CAP_STEREO | | 1892 | vt->capability = V4L2_TUNER_CAP_STEREO | |
1841 | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; | 1893 | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; |
1842 | 1894 | ||
1843 | mode = desc->getmode(chip); | ||
1844 | |||
1845 | if (mode & V4L2_TUNER_MODE_MONO) | ||
1846 | vt->rxsubchans |= V4L2_TUNER_SUB_MONO; | ||
1847 | if (mode & V4L2_TUNER_MODE_STEREO) | ||
1848 | vt->rxsubchans |= V4L2_TUNER_SUB_STEREO; | ||
1849 | /* Note: for SAP it should be mono/lang2 or stereo/lang2. | ||
1850 | When this module is converted fully to v4l2, then this | ||
1851 | should change for those chips that can detect SAP. */ | ||
1852 | if (mode & V4L2_TUNER_MODE_LANG1) | ||
1853 | vt->rxsubchans = V4L2_TUNER_SUB_LANG1 | | ||
1854 | V4L2_TUNER_SUB_LANG2; | ||
1855 | return 0; | 1895 | return 0; |
1856 | } | 1896 | } |
1857 | 1897 | ||
@@ -1868,9 +1908,7 @@ static int tvaudio_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr | |||
1868 | struct CHIPSTATE *chip = to_state(sd); | 1908 | struct CHIPSTATE *chip = to_state(sd); |
1869 | struct CHIPDESC *desc = chip->desc; | 1909 | struct CHIPDESC *desc = chip->desc; |
1870 | 1910 | ||
1871 | chip->mode = 0; /* automatic */ | 1911 | /* For chips that provide getrxsubchans and setaudmode, and doesn't |
1872 | |||
1873 | /* For chips that provide getmode and setmode, and doesn't | ||
1874 | automatically follows the stereo carrier, a kthread is | 1912 | automatically follows the stereo carrier, a kthread is |
1875 | created to set the audio standard. In this case, when then | 1913 | created to set the audio standard. In this case, when then |
1876 | the video channel is changed, tvaudio starts on MONO mode. | 1914 | the video channel is changed, tvaudio starts on MONO mode. |
@@ -1879,9 +1917,8 @@ static int tvaudio_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr | |||
1879 | audio carrier. | 1917 | audio carrier. |
1880 | */ | 1918 | */ |
1881 | if (chip->thread) { | 1919 | if (chip->thread) { |
1882 | desc->setmode(chip, V4L2_TUNER_MODE_MONO); | 1920 | desc->setaudmode(chip, V4L2_TUNER_MODE_MONO); |
1883 | if (chip->prevmode != V4L2_TUNER_MODE_MONO) | 1921 | chip->prevmode = -1; /* reset previous mode */ |
1884 | chip->prevmode = -1; /* reset previous mode */ | ||
1885 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); | 1922 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); |
1886 | } | 1923 | } |
1887 | return 0; | 1924 | return 0; |
@@ -2023,7 +2060,7 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id * | |||
2023 | chip->thread = NULL; | 2060 | chip->thread = NULL; |
2024 | init_timer(&chip->wt); | 2061 | init_timer(&chip->wt); |
2025 | if (desc->flags & CHIP_NEED_CHECKMODE) { | 2062 | if (desc->flags & CHIP_NEED_CHECKMODE) { |
2026 | if (!desc->getmode || !desc->setmode) { | 2063 | if (!desc->getrxsubchans || !desc->setaudmode) { |
2027 | /* This shouldn't be happen. Warn user, but keep working | 2064 | /* This shouldn't be happen. Warn user, but keep working |
2028 | without kthread | 2065 | without kthread |
2029 | */ | 2066 | */ |
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index b7867427e5c4..0d897cb1774a 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c | |||
@@ -61,13 +61,20 @@ static int tvp5150_read(struct v4l2_subdev *sd, unsigned char addr) | |||
61 | int rc; | 61 | int rc; |
62 | 62 | ||
63 | buffer[0] = addr; | 63 | buffer[0] = addr; |
64 | if (1 != (rc = i2c_master_send(c, buffer, 1))) | 64 | |
65 | v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 1)\n", rc); | 65 | rc = i2c_master_send(c, buffer, 1); |
66 | if (rc < 0) { | ||
67 | v4l2_err(sd, "i2c i/o error: rc == %d (should be 1)\n", rc); | ||
68 | return rc; | ||
69 | } | ||
66 | 70 | ||
67 | msleep(10); | 71 | msleep(10); |
68 | 72 | ||
69 | if (1 != (rc = i2c_master_recv(c, buffer, 1))) | 73 | rc = i2c_master_recv(c, buffer, 1); |
70 | v4l2_dbg(0, debug, sd, "i2c i/o error: rc == %d (should be 1)\n", rc); | 74 | if (rc < 0) { |
75 | v4l2_err(sd, "i2c i/o error: rc == %d (should be 1)\n", rc); | ||
76 | return rc; | ||
77 | } | ||
71 | 78 | ||
72 | v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]); | 79 | v4l2_dbg(2, debug, sd, "tvp5150: read 0x%02x = 0x%02x\n", addr, buffer[0]); |
73 | 80 | ||
@@ -279,6 +286,11 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd) | |||
279 | * For Composite and TV, it should be the reverse | 286 | * For Composite and TV, it should be the reverse |
280 | */ | 287 | */ |
281 | val = tvp5150_read(sd, TVP5150_MISC_CTL); | 288 | val = tvp5150_read(sd, TVP5150_MISC_CTL); |
289 | if (val < 0) { | ||
290 | v4l2_err(sd, "%s: failed with error = %d\n", __func__, val); | ||
291 | return; | ||
292 | } | ||
293 | |||
282 | if (decoder->input == TVP5150_SVIDEO) | 294 | if (decoder->input == TVP5150_SVIDEO) |
283 | val = (val & ~0x40) | 0x10; | 295 | val = (val & ~0x40) | 0x10; |
284 | else | 296 | else |
@@ -676,6 +688,7 @@ static int tvp5150_get_vbi(struct v4l2_subdev *sd, | |||
676 | v4l2_std_id std = decoder->norm; | 688 | v4l2_std_id std = decoder->norm; |
677 | u8 reg; | 689 | u8 reg; |
678 | int pos, type = 0; | 690 | int pos, type = 0; |
691 | int i, ret = 0; | ||
679 | 692 | ||
680 | if (std == V4L2_STD_ALL) { | 693 | if (std == V4L2_STD_ALL) { |
681 | v4l2_err(sd, "VBI can't be configured without knowing number of lines\n"); | 694 | v4l2_err(sd, "VBI can't be configured without knowing number of lines\n"); |
@@ -690,13 +703,17 @@ static int tvp5150_get_vbi(struct v4l2_subdev *sd, | |||
690 | 703 | ||
691 | reg = ((line - 6) << 1) + TVP5150_LINE_MODE_INI; | 704 | reg = ((line - 6) << 1) + TVP5150_LINE_MODE_INI; |
692 | 705 | ||
693 | pos = tvp5150_read(sd, reg) & 0x0f; | 706 | for (i = 0; i <= 1; i++) { |
694 | if (pos < 0x0f) | 707 | ret = tvp5150_read(sd, reg + i); |
695 | type = regs[pos].type.vbi_type; | 708 | if (ret < 0) { |
696 | 709 | v4l2_err(sd, "%s: failed with error = %d\n", | |
697 | pos = tvp5150_read(sd, reg + 1) & 0x0f; | 710 | __func__, ret); |
698 | if (pos < 0x0f) | 711 | return 0; |
699 | type |= regs[pos].type.vbi_type; | 712 | } |
713 | pos = ret & 0x0f; | ||
714 | if (pos < 0x0f) | ||
715 | type |= regs[pos].type.vbi_type; | ||
716 | } | ||
700 | 717 | ||
701 | return type; | 718 | return type; |
702 | } | 719 | } |
@@ -1031,13 +1048,21 @@ static int tvp5150_g_chip_ident(struct v4l2_subdev *sd, | |||
1031 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1048 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1032 | static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) | 1049 | static int tvp5150_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) |
1033 | { | 1050 | { |
1051 | int res; | ||
1052 | |||
1034 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 1053 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
1035 | 1054 | ||
1036 | if (!v4l2_chip_match_i2c_client(client, ®->match)) | 1055 | if (!v4l2_chip_match_i2c_client(client, ®->match)) |
1037 | return -EINVAL; | 1056 | return -EINVAL; |
1038 | if (!capable(CAP_SYS_ADMIN)) | 1057 | if (!capable(CAP_SYS_ADMIN)) |
1039 | return -EPERM; | 1058 | return -EPERM; |
1040 | reg->val = tvp5150_read(sd, reg->reg & 0xff); | 1059 | res = tvp5150_read(sd, reg->reg & 0xff); |
1060 | if (res < 0) { | ||
1061 | v4l2_err(sd, "%s: failed with error = %d\n", __func__, res); | ||
1062 | return res; | ||
1063 | } | ||
1064 | |||
1065 | reg->val = res; | ||
1041 | reg->size = 1; | 1066 | reg->size = 1; |
1042 | return 0; | 1067 | return 0; |
1043 | } | 1068 | } |
@@ -1126,7 +1151,8 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1126 | { | 1151 | { |
1127 | struct tvp5150 *core; | 1152 | struct tvp5150 *core; |
1128 | struct v4l2_subdev *sd; | 1153 | struct v4l2_subdev *sd; |
1129 | u8 msb_id, lsb_id, msb_rom, lsb_rom; | 1154 | int tvp5150_id[4]; |
1155 | int i, res; | ||
1130 | 1156 | ||
1131 | /* Check if the adapter supports the needed features */ | 1157 | /* Check if the adapter supports the needed features */ |
1132 | if (!i2c_check_functionality(c->adapter, | 1158 | if (!i2c_check_functionality(c->adapter, |
@@ -1139,26 +1165,37 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1139 | } | 1165 | } |
1140 | sd = &core->sd; | 1166 | sd = &core->sd; |
1141 | v4l2_i2c_subdev_init(sd, c, &tvp5150_ops); | 1167 | v4l2_i2c_subdev_init(sd, c, &tvp5150_ops); |
1168 | |||
1169 | /* | ||
1170 | * Read consequent registers - TVP5150_MSB_DEV_ID, TVP5150_LSB_DEV_ID, | ||
1171 | * TVP5150_ROM_MAJOR_VER, TVP5150_ROM_MINOR_VER | ||
1172 | */ | ||
1173 | for (i = 0; i < 4; i++) { | ||
1174 | res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i); | ||
1175 | if (res < 0) | ||
1176 | goto free_core; | ||
1177 | tvp5150_id[i] = res; | ||
1178 | } | ||
1179 | |||
1142 | v4l_info(c, "chip found @ 0x%02x (%s)\n", | 1180 | v4l_info(c, "chip found @ 0x%02x (%s)\n", |
1143 | c->addr << 1, c->adapter->name); | 1181 | c->addr << 1, c->adapter->name); |
1144 | 1182 | ||
1145 | msb_id = tvp5150_read(sd, TVP5150_MSB_DEV_ID); | 1183 | if (tvp5150_id[2] == 4 && tvp5150_id[3] == 0) { /* Is TVP5150AM1 */ |
1146 | lsb_id = tvp5150_read(sd, TVP5150_LSB_DEV_ID); | 1184 | v4l2_info(sd, "tvp%02x%02xam1 detected.\n", |
1147 | msb_rom = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER); | 1185 | tvp5150_id[0], tvp5150_id[1]); |
1148 | lsb_rom = tvp5150_read(sd, TVP5150_ROM_MINOR_VER); | ||
1149 | |||
1150 | if (msb_rom == 4 && lsb_rom == 0) { /* Is TVP5150AM1 */ | ||
1151 | v4l2_info(sd, "tvp%02x%02xam1 detected.\n", msb_id, lsb_id); | ||
1152 | 1186 | ||
1153 | /* ITU-T BT.656.4 timing */ | 1187 | /* ITU-T BT.656.4 timing */ |
1154 | tvp5150_write(sd, TVP5150_REV_SELECT, 0); | 1188 | tvp5150_write(sd, TVP5150_REV_SELECT, 0); |
1155 | } else { | 1189 | } else { |
1156 | if (msb_rom == 3 || lsb_rom == 0x21) { /* Is TVP5150A */ | 1190 | /* Is TVP5150A */ |
1157 | v4l2_info(sd, "tvp%02x%02xa detected.\n", msb_id, lsb_id); | 1191 | if (tvp5150_id[2] == 3 || tvp5150_id[3] == 0x21) { |
1192 | v4l2_info(sd, "tvp%02x%02xa detected.\n", | ||
1193 | tvp5150_id[2], tvp5150_id[3]); | ||
1158 | } else { | 1194 | } else { |
1159 | v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n", | 1195 | v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n", |
1160 | msb_id, lsb_id); | 1196 | tvp5150_id[2], tvp5150_id[3]); |
1161 | v4l2_info(sd, "*** Rom ver is %d.%d\n", msb_rom, lsb_rom); | 1197 | v4l2_info(sd, "*** Rom ver is %d.%d\n", |
1198 | tvp5150_id[2], tvp5150_id[3]); | ||
1162 | } | 1199 | } |
1163 | } | 1200 | } |
1164 | 1201 | ||
@@ -1177,11 +1214,9 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1177 | V4L2_CID_HUE, -128, 127, 1, 0); | 1214 | V4L2_CID_HUE, -128, 127, 1, 0); |
1178 | sd->ctrl_handler = &core->hdl; | 1215 | sd->ctrl_handler = &core->hdl; |
1179 | if (core->hdl.error) { | 1216 | if (core->hdl.error) { |
1180 | int err = core->hdl.error; | 1217 | res = core->hdl.error; |
1181 | |||
1182 | v4l2_ctrl_handler_free(&core->hdl); | 1218 | v4l2_ctrl_handler_free(&core->hdl); |
1183 | kfree(core); | 1219 | goto free_core; |
1184 | return err; | ||
1185 | } | 1220 | } |
1186 | v4l2_ctrl_handler_setup(&core->hdl); | 1221 | v4l2_ctrl_handler_setup(&core->hdl); |
1187 | 1222 | ||
@@ -1197,6 +1232,10 @@ static int tvp5150_probe(struct i2c_client *c, | |||
1197 | if (debug > 1) | 1232 | if (debug > 1) |
1198 | tvp5150_log_status(sd); | 1233 | tvp5150_log_status(sd); |
1199 | return 0; | 1234 | return 0; |
1235 | |||
1236 | free_core: | ||
1237 | kfree(core); | ||
1238 | return res; | ||
1200 | } | 1239 | } |
1201 | 1240 | ||
1202 | static int tvp5150_remove(struct i2c_client *c) | 1241 | static int tvp5150_remove(struct i2c_client *c) |
diff --git a/drivers/media/video/uvc/Kconfig b/drivers/media/video/uvc/Kconfig index 6c197da531b2..541c9f1e4c6a 100644 --- a/drivers/media/video/uvc/Kconfig +++ b/drivers/media/video/uvc/Kconfig | |||
@@ -10,6 +10,7 @@ config USB_VIDEO_CLASS | |||
10 | config USB_VIDEO_CLASS_INPUT_EVDEV | 10 | config USB_VIDEO_CLASS_INPUT_EVDEV |
11 | bool "UVC input events device support" | 11 | bool "UVC input events device support" |
12 | default y | 12 | default y |
13 | depends on USB_VIDEO_CLASS | ||
13 | depends on USB_VIDEO_CLASS=INPUT || INPUT=y | 14 | depends on USB_VIDEO_CLASS=INPUT || INPUT=y |
14 | ---help--- | 15 | ---help--- |
15 | This option makes USB Video Class devices register an input device | 16 | This option makes USB Video Class devices register an input device |
diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c index 759bef8897e9..f00db3060e0e 100644 --- a/drivers/media/video/uvc/uvc_v4l2.c +++ b/drivers/media/video/uvc/uvc_v4l2.c | |||
@@ -1051,7 +1051,7 @@ static long uvc_v4l2_ioctl(struct file *file, | |||
1051 | { | 1051 | { |
1052 | if (uvc_trace_param & UVC_TRACE_IOCTL) { | 1052 | if (uvc_trace_param & UVC_TRACE_IOCTL) { |
1053 | uvc_printk(KERN_DEBUG, "uvc_v4l2_ioctl("); | 1053 | uvc_printk(KERN_DEBUG, "uvc_v4l2_ioctl("); |
1054 | v4l_printk_ioctl(cmd); | 1054 | v4l_printk_ioctl(NULL, cmd); |
1055 | printk(")\n"); | 1055 | printk(")\n"); |
1056 | } | 1056 | } |
1057 | 1057 | ||
diff --git a/drivers/media/video/uvc/uvc_video.c b/drivers/media/video/uvc/uvc_video.c index b76b0ac0958f..7ac4347ca09e 100644 --- a/drivers/media/video/uvc/uvc_video.c +++ b/drivers/media/video/uvc/uvc_video.c | |||
@@ -1188,7 +1188,11 @@ static void uvc_video_decode_bulk(struct urb *urb, struct uvc_streaming *stream, | |||
1188 | u8 *mem; | 1188 | u8 *mem; |
1189 | int len, ret; | 1189 | int len, ret; |
1190 | 1190 | ||
1191 | if (urb->actual_length == 0) | 1191 | /* |
1192 | * Ignore ZLPs if they're not part of a frame, otherwise process them | ||
1193 | * to trigger the end of payload detection. | ||
1194 | */ | ||
1195 | if (urb->actual_length == 0 && stream->bulk.header_size == 0) | ||
1192 | return; | 1196 | return; |
1193 | 1197 | ||
1194 | mem = urb->transfer_buffer; | 1198 | mem = urb->transfer_buffer; |
@@ -1594,7 +1598,7 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags) | |||
1594 | psize = le16_to_cpu(ep->desc.wMaxPacketSize); | 1598 | psize = le16_to_cpu(ep->desc.wMaxPacketSize); |
1595 | psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); | 1599 | psize = (psize & 0x07ff) * (1 + ((psize >> 11) & 3)); |
1596 | if (psize >= bandwidth && psize <= best_psize) { | 1600 | if (psize >= bandwidth && psize <= best_psize) { |
1597 | altsetting = i; | 1601 | altsetting = alts->desc.bAlternateSetting; |
1598 | best_psize = psize; | 1602 | best_psize = psize; |
1599 | best_ep = ep; | 1603 | best_ep = ep; |
1600 | } | 1604 | } |
diff --git a/drivers/media/video/v4l2-compat-ioctl32.c b/drivers/media/video/v4l2-compat-ioctl32.c index 5327ad3a6390..ac365cfb3706 100644 --- a/drivers/media/video/v4l2-compat-ioctl32.c +++ b/drivers/media/video/v4l2-compat-ioctl32.c | |||
@@ -327,7 +327,7 @@ struct v4l2_buffer32 { | |||
327 | compat_caddr_t planes; | 327 | compat_caddr_t planes; |
328 | } m; | 328 | } m; |
329 | __u32 length; | 329 | __u32 length; |
330 | __u32 input; | 330 | __u32 reserved2; |
331 | __u32 reserved; | 331 | __u32 reserved; |
332 | }; | 332 | }; |
333 | 333 | ||
@@ -387,8 +387,7 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user | |||
387 | get_user(kp->index, &up->index) || | 387 | get_user(kp->index, &up->index) || |
388 | get_user(kp->type, &up->type) || | 388 | get_user(kp->type, &up->type) || |
389 | get_user(kp->flags, &up->flags) || | 389 | get_user(kp->flags, &up->flags) || |
390 | get_user(kp->memory, &up->memory) || | 390 | get_user(kp->memory, &up->memory)) |
391 | get_user(kp->input, &up->input)) | ||
392 | return -EFAULT; | 391 | return -EFAULT; |
393 | 392 | ||
394 | if (V4L2_TYPE_IS_OUTPUT(kp->type)) | 393 | if (V4L2_TYPE_IS_OUTPUT(kp->type)) |
@@ -472,8 +471,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user | |||
472 | put_user(kp->index, &up->index) || | 471 | put_user(kp->index, &up->index) || |
473 | put_user(kp->type, &up->type) || | 472 | put_user(kp->type, &up->type) || |
474 | put_user(kp->flags, &up->flags) || | 473 | put_user(kp->flags, &up->flags) || |
475 | put_user(kp->memory, &up->memory) || | 474 | put_user(kp->memory, &up->memory)) |
476 | put_user(kp->input, &up->input)) | ||
477 | return -EFAULT; | 475 | return -EFAULT; |
478 | 476 | ||
479 | if (put_user(kp->bytesused, &up->bytesused) || | 477 | if (put_user(kp->bytesused, &up->bytesused) || |
@@ -482,6 +480,7 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user | |||
482 | put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec) || | 480 | put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec) || |
483 | copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) || | 481 | copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) || |
484 | put_user(kp->sequence, &up->sequence) || | 482 | put_user(kp->sequence, &up->sequence) || |
483 | put_user(kp->reserved2, &up->reserved2) || | ||
485 | put_user(kp->reserved, &up->reserved)) | 484 | put_user(kp->reserved, &up->reserved)) |
486 | return -EFAULT; | 485 | return -EFAULT; |
487 | 486 | ||
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 83dbb2ddff10..d13c47fc7202 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -46,6 +46,29 @@ static ssize_t show_index(struct device *cd, | |||
46 | return sprintf(buf, "%i\n", vdev->index); | 46 | return sprintf(buf, "%i\n", vdev->index); |
47 | } | 47 | } |
48 | 48 | ||
49 | static ssize_t show_debug(struct device *cd, | ||
50 | struct device_attribute *attr, char *buf) | ||
51 | { | ||
52 | struct video_device *vdev = to_video_device(cd); | ||
53 | |||
54 | return sprintf(buf, "%i\n", vdev->debug); | ||
55 | } | ||
56 | |||
57 | static ssize_t set_debug(struct device *cd, struct device_attribute *attr, | ||
58 | const char *buf, size_t len) | ||
59 | { | ||
60 | struct video_device *vdev = to_video_device(cd); | ||
61 | int res = 0; | ||
62 | u16 value; | ||
63 | |||
64 | res = kstrtou16(buf, 0, &value); | ||
65 | if (res) | ||
66 | return res; | ||
67 | |||
68 | vdev->debug = value; | ||
69 | return len; | ||
70 | } | ||
71 | |||
49 | static ssize_t show_name(struct device *cd, | 72 | static ssize_t show_name(struct device *cd, |
50 | struct device_attribute *attr, char *buf) | 73 | struct device_attribute *attr, char *buf) |
51 | { | 74 | { |
@@ -56,6 +79,7 @@ static ssize_t show_name(struct device *cd, | |||
56 | 79 | ||
57 | static struct device_attribute video_device_attrs[] = { | 80 | static struct device_attribute video_device_attrs[] = { |
58 | __ATTR(name, S_IRUGO, show_name, NULL), | 81 | __ATTR(name, S_IRUGO, show_name, NULL), |
82 | __ATTR(debug, 0644, show_debug, set_debug), | ||
59 | __ATTR(index, S_IRUGO, show_index, NULL), | 83 | __ATTR(index, S_IRUGO, show_index, NULL), |
60 | __ATTR_NULL | 84 | __ATTR_NULL |
61 | }; | 85 | }; |
@@ -281,6 +305,9 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf, | |||
281 | ret = vdev->fops->read(filp, buf, sz, off); | 305 | ret = vdev->fops->read(filp, buf, sz, off); |
282 | if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) | 306 | if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) |
283 | mutex_unlock(vdev->lock); | 307 | mutex_unlock(vdev->lock); |
308 | if (vdev->debug) | ||
309 | printk(KERN_DEBUG "%s: read: %zd (%d)\n", | ||
310 | video_device_node_name(vdev), sz, ret); | ||
284 | return ret; | 311 | return ret; |
285 | } | 312 | } |
286 | 313 | ||
@@ -299,6 +326,9 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf, | |||
299 | ret = vdev->fops->write(filp, buf, sz, off); | 326 | ret = vdev->fops->write(filp, buf, sz, off); |
300 | if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) | 327 | if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) |
301 | mutex_unlock(vdev->lock); | 328 | mutex_unlock(vdev->lock); |
329 | if (vdev->debug) | ||
330 | printk(KERN_DEBUG "%s: write: %zd (%d)\n", | ||
331 | video_device_node_name(vdev), sz, ret); | ||
302 | return ret; | 332 | return ret; |
303 | } | 333 | } |
304 | 334 | ||
@@ -315,6 +345,9 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll) | |||
315 | ret = vdev->fops->poll(filp, poll); | 345 | ret = vdev->fops->poll(filp, poll); |
316 | if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) | 346 | if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) |
317 | mutex_unlock(vdev->lock); | 347 | mutex_unlock(vdev->lock); |
348 | if (vdev->debug) | ||
349 | printk(KERN_DEBUG "%s: poll: %08x\n", | ||
350 | video_device_node_name(vdev), ret); | ||
318 | return ret; | 351 | return ret; |
319 | } | 352 | } |
320 | 353 | ||
@@ -324,20 +357,14 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
324 | int ret = -ENODEV; | 357 | int ret = -ENODEV; |
325 | 358 | ||
326 | if (vdev->fops->unlocked_ioctl) { | 359 | if (vdev->fops->unlocked_ioctl) { |
327 | bool locked = false; | 360 | struct mutex *lock = v4l2_ioctl_get_lock(vdev, cmd); |
328 | 361 | ||
329 | if (vdev->lock) { | 362 | if (lock && mutex_lock_interruptible(lock)) |
330 | /* always lock unless the cmd is marked as "don't use lock" */ | 363 | return -ERESTARTSYS; |
331 | locked = !v4l2_is_known_ioctl(cmd) || | ||
332 | !test_bit(_IOC_NR(cmd), vdev->disable_locking); | ||
333 | |||
334 | if (locked && mutex_lock_interruptible(vdev->lock)) | ||
335 | return -ERESTARTSYS; | ||
336 | } | ||
337 | if (video_is_registered(vdev)) | 364 | if (video_is_registered(vdev)) |
338 | ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); | 365 | ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); |
339 | if (locked) | 366 | if (lock) |
340 | mutex_unlock(vdev->lock); | 367 | mutex_unlock(lock); |
341 | } else if (vdev->fops->ioctl) { | 368 | } else if (vdev->fops->ioctl) { |
342 | /* This code path is a replacement for the BKL. It is a major | 369 | /* This code path is a replacement for the BKL. It is a major |
343 | * hack but it will have to do for those drivers that are not | 370 | * hack but it will have to do for those drivers that are not |
@@ -385,12 +412,17 @@ static unsigned long v4l2_get_unmapped_area(struct file *filp, | |||
385 | unsigned long flags) | 412 | unsigned long flags) |
386 | { | 413 | { |
387 | struct video_device *vdev = video_devdata(filp); | 414 | struct video_device *vdev = video_devdata(filp); |
415 | int ret; | ||
388 | 416 | ||
389 | if (!vdev->fops->get_unmapped_area) | 417 | if (!vdev->fops->get_unmapped_area) |
390 | return -ENOSYS; | 418 | return -ENOSYS; |
391 | if (!video_is_registered(vdev)) | 419 | if (!video_is_registered(vdev)) |
392 | return -ENODEV; | 420 | return -ENODEV; |
393 | return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); | 421 | ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); |
422 | if (vdev->debug) | ||
423 | printk(KERN_DEBUG "%s: get_unmapped_area (%d)\n", | ||
424 | video_device_node_name(vdev), ret); | ||
425 | return ret; | ||
394 | } | 426 | } |
395 | #endif | 427 | #endif |
396 | 428 | ||
@@ -408,6 +440,9 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm) | |||
408 | ret = vdev->fops->mmap(filp, vm); | 440 | ret = vdev->fops->mmap(filp, vm); |
409 | if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) | 441 | if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags)) |
410 | mutex_unlock(vdev->lock); | 442 | mutex_unlock(vdev->lock); |
443 | if (vdev->debug) | ||
444 | printk(KERN_DEBUG "%s: mmap (%d)\n", | ||
445 | video_device_node_name(vdev), ret); | ||
411 | return ret; | 446 | return ret; |
412 | } | 447 | } |
413 | 448 | ||
@@ -446,6 +481,9 @@ err: | |||
446 | /* decrease the refcount in case of an error */ | 481 | /* decrease the refcount in case of an error */ |
447 | if (ret) | 482 | if (ret) |
448 | video_put(vdev); | 483 | video_put(vdev); |
484 | if (vdev->debug) | ||
485 | printk(KERN_DEBUG "%s: open (%d)\n", | ||
486 | video_device_node_name(vdev), ret); | ||
449 | return ret; | 487 | return ret; |
450 | } | 488 | } |
451 | 489 | ||
@@ -465,6 +503,9 @@ static int v4l2_release(struct inode *inode, struct file *filp) | |||
465 | /* decrease the refcount unconditionally since the release() | 503 | /* decrease the refcount unconditionally since the release() |
466 | return value is ignored. */ | 504 | return value is ignored. */ |
467 | video_put(vdev); | 505 | video_put(vdev); |
506 | if (vdev->debug) | ||
507 | printk(KERN_DEBUG "%s: release\n", | ||
508 | video_device_node_name(vdev)); | ||
468 | return ret; | 509 | return ret; |
469 | } | 510 | } |
470 | 511 | ||
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index d7fa8962d8b3..70e0efb127a6 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -27,27 +27,7 @@ | |||
27 | #include <media/v4l2-event.h> | 27 | #include <media/v4l2-event.h> |
28 | #include <media/v4l2-device.h> | 28 | #include <media/v4l2-device.h> |
29 | #include <media/v4l2-chip-ident.h> | 29 | #include <media/v4l2-chip-ident.h> |
30 | 30 | #include <media/videobuf2-core.h> | |
31 | #define dbgarg(cmd, fmt, arg...) \ | ||
32 | do { \ | ||
33 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \ | ||
34 | printk(KERN_DEBUG "%s: ", vfd->name); \ | ||
35 | v4l_printk_ioctl(cmd); \ | ||
36 | printk(" " fmt, ## arg); \ | ||
37 | } \ | ||
38 | } while (0) | ||
39 | |||
40 | #define dbgarg2(fmt, arg...) \ | ||
41 | do { \ | ||
42 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ | ||
43 | printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\ | ||
44 | } while (0) | ||
45 | |||
46 | #define dbgarg3(fmt, arg...) \ | ||
47 | do { \ | ||
48 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ | ||
49 | printk(KERN_CONT "%s: " fmt, vfd->name, ## arg);\ | ||
50 | } while (0) | ||
51 | 31 | ||
52 | /* Zero out the end of the struct pointed to by p. Everything after, but | 32 | /* Zero out the end of the struct pointed to by p. Everything after, but |
53 | * not including, the specified field is cleared. */ | 33 | * not including, the specified field is cleared. */ |
@@ -183,207 +163,507 @@ static const char *v4l2_memory_names[] = { | |||
183 | /* ------------------------------------------------------------------ */ | 163 | /* ------------------------------------------------------------------ */ |
184 | /* debug help functions */ | 164 | /* debug help functions */ |
185 | 165 | ||
186 | struct v4l2_ioctl_info { | 166 | static void v4l_print_querycap(const void *arg, bool write_only) |
187 | unsigned int ioctl; | 167 | { |
188 | u16 flags; | 168 | const struct v4l2_capability *p = arg; |
189 | const char * const name; | ||
190 | }; | ||
191 | 169 | ||
192 | /* This control needs a priority check */ | 170 | pr_cont("driver=%s, card=%s, bus=%s, version=0x%08x, " |
193 | #define INFO_FL_PRIO (1 << 0) | 171 | "capabilities=0x%08x, device_caps=0x%08x\n", |
194 | /* This control can be valid if the filehandle passes a control handler. */ | 172 | p->driver, p->card, p->bus_info, |
195 | #define INFO_FL_CTRL (1 << 1) | 173 | p->version, p->capabilities, p->device_caps); |
174 | } | ||
196 | 175 | ||
197 | #define IOCTL_INFO(_ioctl, _flags) [_IOC_NR(_ioctl)] = { \ | 176 | static void v4l_print_enuminput(const void *arg, bool write_only) |
198 | .ioctl = _ioctl, \ | 177 | { |
199 | .flags = _flags, \ | 178 | const struct v4l2_input *p = arg; |
200 | .name = #_ioctl, \ | 179 | |
180 | pr_cont("index=%u, name=%s, type=%u, audioset=0x%x, tuner=%u, " | ||
181 | "std=0x%08Lx, status=0x%x, capabilities=0x%x\n", | ||
182 | p->index, p->name, p->type, p->audioset, p->tuner, | ||
183 | (unsigned long long)p->std, p->status, p->capabilities); | ||
201 | } | 184 | } |
202 | 185 | ||
203 | static struct v4l2_ioctl_info v4l2_ioctls[] = { | 186 | static void v4l_print_enumoutput(const void *arg, bool write_only) |
204 | IOCTL_INFO(VIDIOC_QUERYCAP, 0), | 187 | { |
205 | IOCTL_INFO(VIDIOC_ENUM_FMT, 0), | 188 | const struct v4l2_output *p = arg; |
206 | IOCTL_INFO(VIDIOC_G_FMT, 0), | ||
207 | IOCTL_INFO(VIDIOC_S_FMT, INFO_FL_PRIO), | ||
208 | IOCTL_INFO(VIDIOC_REQBUFS, INFO_FL_PRIO), | ||
209 | IOCTL_INFO(VIDIOC_QUERYBUF, 0), | ||
210 | IOCTL_INFO(VIDIOC_G_FBUF, 0), | ||
211 | IOCTL_INFO(VIDIOC_S_FBUF, INFO_FL_PRIO), | ||
212 | IOCTL_INFO(VIDIOC_OVERLAY, INFO_FL_PRIO), | ||
213 | IOCTL_INFO(VIDIOC_QBUF, 0), | ||
214 | IOCTL_INFO(VIDIOC_DQBUF, 0), | ||
215 | IOCTL_INFO(VIDIOC_STREAMON, INFO_FL_PRIO), | ||
216 | IOCTL_INFO(VIDIOC_STREAMOFF, INFO_FL_PRIO), | ||
217 | IOCTL_INFO(VIDIOC_G_PARM, 0), | ||
218 | IOCTL_INFO(VIDIOC_S_PARM, INFO_FL_PRIO), | ||
219 | IOCTL_INFO(VIDIOC_G_STD, 0), | ||
220 | IOCTL_INFO(VIDIOC_S_STD, INFO_FL_PRIO), | ||
221 | IOCTL_INFO(VIDIOC_ENUMSTD, 0), | ||
222 | IOCTL_INFO(VIDIOC_ENUMINPUT, 0), | ||
223 | IOCTL_INFO(VIDIOC_G_CTRL, INFO_FL_CTRL), | ||
224 | IOCTL_INFO(VIDIOC_S_CTRL, INFO_FL_PRIO | INFO_FL_CTRL), | ||
225 | IOCTL_INFO(VIDIOC_G_TUNER, 0), | ||
226 | IOCTL_INFO(VIDIOC_S_TUNER, INFO_FL_PRIO), | ||
227 | IOCTL_INFO(VIDIOC_G_AUDIO, 0), | ||
228 | IOCTL_INFO(VIDIOC_S_AUDIO, INFO_FL_PRIO), | ||
229 | IOCTL_INFO(VIDIOC_QUERYCTRL, INFO_FL_CTRL), | ||
230 | IOCTL_INFO(VIDIOC_QUERYMENU, INFO_FL_CTRL), | ||
231 | IOCTL_INFO(VIDIOC_G_INPUT, 0), | ||
232 | IOCTL_INFO(VIDIOC_S_INPUT, INFO_FL_PRIO), | ||
233 | IOCTL_INFO(VIDIOC_G_OUTPUT, 0), | ||
234 | IOCTL_INFO(VIDIOC_S_OUTPUT, INFO_FL_PRIO), | ||
235 | IOCTL_INFO(VIDIOC_ENUMOUTPUT, 0), | ||
236 | IOCTL_INFO(VIDIOC_G_AUDOUT, 0), | ||
237 | IOCTL_INFO(VIDIOC_S_AUDOUT, INFO_FL_PRIO), | ||
238 | IOCTL_INFO(VIDIOC_G_MODULATOR, 0), | ||
239 | IOCTL_INFO(VIDIOC_S_MODULATOR, INFO_FL_PRIO), | ||
240 | IOCTL_INFO(VIDIOC_G_FREQUENCY, 0), | ||
241 | IOCTL_INFO(VIDIOC_S_FREQUENCY, INFO_FL_PRIO), | ||
242 | IOCTL_INFO(VIDIOC_CROPCAP, 0), | ||
243 | IOCTL_INFO(VIDIOC_G_CROP, 0), | ||
244 | IOCTL_INFO(VIDIOC_S_CROP, INFO_FL_PRIO), | ||
245 | IOCTL_INFO(VIDIOC_G_SELECTION, 0), | ||
246 | IOCTL_INFO(VIDIOC_S_SELECTION, INFO_FL_PRIO), | ||
247 | IOCTL_INFO(VIDIOC_G_JPEGCOMP, 0), | ||
248 | IOCTL_INFO(VIDIOC_S_JPEGCOMP, INFO_FL_PRIO), | ||
249 | IOCTL_INFO(VIDIOC_QUERYSTD, 0), | ||
250 | IOCTL_INFO(VIDIOC_TRY_FMT, 0), | ||
251 | IOCTL_INFO(VIDIOC_ENUMAUDIO, 0), | ||
252 | IOCTL_INFO(VIDIOC_ENUMAUDOUT, 0), | ||
253 | IOCTL_INFO(VIDIOC_G_PRIORITY, 0), | ||
254 | IOCTL_INFO(VIDIOC_S_PRIORITY, INFO_FL_PRIO), | ||
255 | IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, 0), | ||
256 | IOCTL_INFO(VIDIOC_LOG_STATUS, 0), | ||
257 | IOCTL_INFO(VIDIOC_G_EXT_CTRLS, INFO_FL_CTRL), | ||
258 | IOCTL_INFO(VIDIOC_S_EXT_CTRLS, INFO_FL_PRIO | INFO_FL_CTRL), | ||
259 | IOCTL_INFO(VIDIOC_TRY_EXT_CTRLS, 0), | ||
260 | IOCTL_INFO(VIDIOC_ENUM_FRAMESIZES, 0), | ||
261 | IOCTL_INFO(VIDIOC_ENUM_FRAMEINTERVALS, 0), | ||
262 | IOCTL_INFO(VIDIOC_G_ENC_INDEX, 0), | ||
263 | IOCTL_INFO(VIDIOC_ENCODER_CMD, INFO_FL_PRIO), | ||
264 | IOCTL_INFO(VIDIOC_TRY_ENCODER_CMD, 0), | ||
265 | IOCTL_INFO(VIDIOC_DECODER_CMD, INFO_FL_PRIO), | ||
266 | IOCTL_INFO(VIDIOC_TRY_DECODER_CMD, 0), | ||
267 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
268 | IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0), | ||
269 | IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0), | ||
270 | #endif | ||
271 | IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0), | ||
272 | IOCTL_INFO(VIDIOC_S_HW_FREQ_SEEK, INFO_FL_PRIO), | ||
273 | IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0), | ||
274 | IOCTL_INFO(VIDIOC_S_DV_PRESET, INFO_FL_PRIO), | ||
275 | IOCTL_INFO(VIDIOC_G_DV_PRESET, 0), | ||
276 | IOCTL_INFO(VIDIOC_QUERY_DV_PRESET, 0), | ||
277 | IOCTL_INFO(VIDIOC_S_DV_TIMINGS, INFO_FL_PRIO), | ||
278 | IOCTL_INFO(VIDIOC_G_DV_TIMINGS, 0), | ||
279 | IOCTL_INFO(VIDIOC_DQEVENT, 0), | ||
280 | IOCTL_INFO(VIDIOC_SUBSCRIBE_EVENT, 0), | ||
281 | IOCTL_INFO(VIDIOC_UNSUBSCRIBE_EVENT, 0), | ||
282 | IOCTL_INFO(VIDIOC_CREATE_BUFS, INFO_FL_PRIO), | ||
283 | IOCTL_INFO(VIDIOC_PREPARE_BUF, 0), | ||
284 | IOCTL_INFO(VIDIOC_ENUM_DV_TIMINGS, 0), | ||
285 | IOCTL_INFO(VIDIOC_QUERY_DV_TIMINGS, 0), | ||
286 | IOCTL_INFO(VIDIOC_DV_TIMINGS_CAP, 0), | ||
287 | }; | ||
288 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | ||
289 | 189 | ||
290 | bool v4l2_is_known_ioctl(unsigned int cmd) | 190 | pr_cont("index=%u, name=%s, type=%u, audioset=0x%x, " |
191 | "modulator=%u, std=0x%08Lx, capabilities=0x%x\n", | ||
192 | p->index, p->name, p->type, p->audioset, p->modulator, | ||
193 | (unsigned long long)p->std, p->capabilities); | ||
194 | } | ||
195 | |||
196 | static void v4l_print_audio(const void *arg, bool write_only) | ||
291 | { | 197 | { |
292 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) | 198 | const struct v4l2_audio *p = arg; |
293 | return false; | 199 | |
294 | return v4l2_ioctls[_IOC_NR(cmd)].ioctl == cmd; | 200 | if (write_only) |
201 | pr_cont("index=%u, mode=0x%x\n", p->index, p->mode); | ||
202 | else | ||
203 | pr_cont("index=%u, name=%s, capability=0x%x, mode=0x%x\n", | ||
204 | p->index, p->name, p->capability, p->mode); | ||
295 | } | 205 | } |
296 | 206 | ||
297 | /* Common ioctl debug function. This function can be used by | 207 | static void v4l_print_audioout(const void *arg, bool write_only) |
298 | external ioctl messages as well as internal V4L ioctl */ | ||
299 | void v4l_printk_ioctl(unsigned int cmd) | ||
300 | { | 208 | { |
301 | char *dir, *type; | 209 | const struct v4l2_audioout *p = arg; |
302 | 210 | ||
303 | switch (_IOC_TYPE(cmd)) { | 211 | if (write_only) |
304 | case 'd': | 212 | pr_cont("index=%u\n", p->index); |
305 | type = "v4l2_int"; | 213 | else |
214 | pr_cont("index=%u, name=%s, capability=0x%x, mode=0x%x\n", | ||
215 | p->index, p->name, p->capability, p->mode); | ||
216 | } | ||
217 | |||
218 | static void v4l_print_fmtdesc(const void *arg, bool write_only) | ||
219 | { | ||
220 | const struct v4l2_fmtdesc *p = arg; | ||
221 | |||
222 | pr_cont("index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, description='%s'\n", | ||
223 | p->index, prt_names(p->type, v4l2_type_names), | ||
224 | p->flags, (p->pixelformat & 0xff), | ||
225 | (p->pixelformat >> 8) & 0xff, | ||
226 | (p->pixelformat >> 16) & 0xff, | ||
227 | (p->pixelformat >> 24) & 0xff, | ||
228 | p->description); | ||
229 | } | ||
230 | |||
231 | static void v4l_print_format(const void *arg, bool write_only) | ||
232 | { | ||
233 | const struct v4l2_format *p = arg; | ||
234 | const struct v4l2_pix_format *pix; | ||
235 | const struct v4l2_pix_format_mplane *mp; | ||
236 | const struct v4l2_vbi_format *vbi; | ||
237 | const struct v4l2_sliced_vbi_format *sliced; | ||
238 | const struct v4l2_window *win; | ||
239 | const struct v4l2_clip *clip; | ||
240 | unsigned i; | ||
241 | |||
242 | pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); | ||
243 | switch (p->type) { | ||
244 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
245 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | ||
246 | pix = &p->fmt.pix; | ||
247 | pr_cont(", width=%u, height=%u, " | ||
248 | "pixelformat=%c%c%c%c, field=%s, " | ||
249 | "bytesperline=%u sizeimage=%u, colorspace=%d\n", | ||
250 | pix->width, pix->height, | ||
251 | (pix->pixelformat & 0xff), | ||
252 | (pix->pixelformat >> 8) & 0xff, | ||
253 | (pix->pixelformat >> 16) & 0xff, | ||
254 | (pix->pixelformat >> 24) & 0xff, | ||
255 | prt_names(pix->field, v4l2_field_names), | ||
256 | pix->bytesperline, pix->sizeimage, | ||
257 | pix->colorspace); | ||
306 | break; | 258 | break; |
307 | case 'V': | 259 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
308 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) { | 260 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
309 | type = "v4l2"; | 261 | mp = &p->fmt.pix_mp; |
310 | break; | 262 | pr_cont(", width=%u, height=%u, " |
263 | "format=%c%c%c%c, field=%s, " | ||
264 | "colorspace=%d, num_planes=%u\n", | ||
265 | mp->width, mp->height, | ||
266 | (mp->pixelformat & 0xff), | ||
267 | (mp->pixelformat >> 8) & 0xff, | ||
268 | (mp->pixelformat >> 16) & 0xff, | ||
269 | (mp->pixelformat >> 24) & 0xff, | ||
270 | prt_names(mp->field, v4l2_field_names), | ||
271 | mp->colorspace, mp->num_planes); | ||
272 | for (i = 0; i < mp->num_planes; i++) | ||
273 | printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i, | ||
274 | mp->plane_fmt[i].bytesperline, | ||
275 | mp->plane_fmt[i].sizeimage); | ||
276 | break; | ||
277 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
278 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: | ||
279 | win = &p->fmt.win; | ||
280 | pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, " | ||
281 | "chromakey=0x%08x, bitmap=%p, " | ||
282 | "global_alpha=0x%02x\n", | ||
283 | win->w.width, win->w.height, | ||
284 | win->w.left, win->w.top, | ||
285 | prt_names(win->field, v4l2_field_names), | ||
286 | win->chromakey, win->bitmap, win->global_alpha); | ||
287 | clip = win->clips; | ||
288 | for (i = 0; i < win->clipcount; i++) { | ||
289 | printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n", | ||
290 | i, clip->c.width, clip->c.height, | ||
291 | clip->c.left, clip->c.top); | ||
292 | clip = clip->next; | ||
311 | } | 293 | } |
312 | printk("%s", v4l2_ioctls[_IOC_NR(cmd)].name); | 294 | break; |
313 | return; | 295 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
314 | default: | 296 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
315 | type = "unknown"; | 297 | vbi = &p->fmt.vbi; |
298 | pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, " | ||
299 | "sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n", | ||
300 | vbi->sampling_rate, vbi->offset, | ||
301 | vbi->samples_per_line, | ||
302 | (vbi->sample_format & 0xff), | ||
303 | (vbi->sample_format >> 8) & 0xff, | ||
304 | (vbi->sample_format >> 16) & 0xff, | ||
305 | (vbi->sample_format >> 24) & 0xff, | ||
306 | vbi->start[0], vbi->start[1], | ||
307 | vbi->count[0], vbi->count[1]); | ||
308 | break; | ||
309 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | ||
310 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | ||
311 | sliced = &p->fmt.sliced; | ||
312 | pr_cont(", service_set=0x%08x, io_size=%d\n", | ||
313 | sliced->service_set, sliced->io_size); | ||
314 | for (i = 0; i < 24; i++) | ||
315 | printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i, | ||
316 | sliced->service_lines[0][i], | ||
317 | sliced->service_lines[1][i]); | ||
318 | break; | ||
319 | case V4L2_BUF_TYPE_PRIVATE: | ||
320 | pr_cont("\n"); | ||
321 | break; | ||
316 | } | 322 | } |
323 | } | ||
317 | 324 | ||
318 | switch (_IOC_DIR(cmd)) { | 325 | static void v4l_print_framebuffer(const void *arg, bool write_only) |
319 | case _IOC_NONE: dir = "--"; break; | 326 | { |
320 | case _IOC_READ: dir = "r-"; break; | 327 | const struct v4l2_framebuffer *p = arg; |
321 | case _IOC_WRITE: dir = "-w"; break; | 328 | |
322 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; | 329 | pr_cont("capability=0x%x, flags=0x%x, base=0x%p, width=%u, " |
323 | default: dir = "*ERR*"; break; | 330 | "height=%u, pixelformat=%c%c%c%c, " |
324 | } | 331 | "bytesperline=%u sizeimage=%u, colorspace=%d\n", |
325 | printk("%s ioctl '%c', dir=%s, #%d (0x%08x)", | 332 | p->capability, p->flags, p->base, |
326 | type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); | 333 | p->fmt.width, p->fmt.height, |
334 | (p->fmt.pixelformat & 0xff), | ||
335 | (p->fmt.pixelformat >> 8) & 0xff, | ||
336 | (p->fmt.pixelformat >> 16) & 0xff, | ||
337 | (p->fmt.pixelformat >> 24) & 0xff, | ||
338 | p->fmt.bytesperline, p->fmt.sizeimage, | ||
339 | p->fmt.colorspace); | ||
340 | } | ||
341 | |||
342 | static void v4l_print_buftype(const void *arg, bool write_only) | ||
343 | { | ||
344 | pr_cont("type=%s\n", prt_names(*(u32 *)arg, v4l2_type_names)); | ||
345 | } | ||
346 | |||
347 | static void v4l_print_modulator(const void *arg, bool write_only) | ||
348 | { | ||
349 | const struct v4l2_modulator *p = arg; | ||
350 | |||
351 | if (write_only) | ||
352 | pr_cont("index=%u, txsubchans=0x%x", p->index, p->txsubchans); | ||
353 | else | ||
354 | pr_cont("index=%u, name=%s, capability=0x%x, " | ||
355 | "rangelow=%u, rangehigh=%u, txsubchans=0x%x\n", | ||
356 | p->index, p->name, p->capability, | ||
357 | p->rangelow, p->rangehigh, p->txsubchans); | ||
358 | } | ||
359 | |||
360 | static void v4l_print_tuner(const void *arg, bool write_only) | ||
361 | { | ||
362 | const struct v4l2_tuner *p = arg; | ||
363 | |||
364 | if (write_only) | ||
365 | pr_cont("index=%u, audmode=%u\n", p->index, p->audmode); | ||
366 | else | ||
367 | pr_cont("index=%u, name=%s, type=%u, capability=0x%x, " | ||
368 | "rangelow=%u, rangehigh=%u, signal=%u, afc=%d, " | ||
369 | "rxsubchans=0x%x, audmode=%u\n", | ||
370 | p->index, p->name, p->type, | ||
371 | p->capability, p->rangelow, | ||
372 | p->rangehigh, p->signal, p->afc, | ||
373 | p->rxsubchans, p->audmode); | ||
374 | } | ||
375 | |||
376 | static void v4l_print_frequency(const void *arg, bool write_only) | ||
377 | { | ||
378 | const struct v4l2_frequency *p = arg; | ||
379 | |||
380 | pr_cont("tuner=%u, type=%u, frequency=%u\n", | ||
381 | p->tuner, p->type, p->frequency); | ||
382 | } | ||
383 | |||
384 | static void v4l_print_standard(const void *arg, bool write_only) | ||
385 | { | ||
386 | const struct v4l2_standard *p = arg; | ||
387 | |||
388 | pr_cont("index=%u, id=0x%Lx, name=%s, fps=%u/%u, " | ||
389 | "framelines=%u\n", p->index, | ||
390 | (unsigned long long)p->id, p->name, | ||
391 | p->frameperiod.numerator, | ||
392 | p->frameperiod.denominator, | ||
393 | p->framelines); | ||
394 | } | ||
395 | |||
396 | static void v4l_print_std(const void *arg, bool write_only) | ||
397 | { | ||
398 | pr_cont("std=0x%08Lx\n", *(const long long unsigned *)arg); | ||
327 | } | 399 | } |
328 | EXPORT_SYMBOL(v4l_printk_ioctl); | ||
329 | 400 | ||
330 | static void dbgbuf(unsigned int cmd, struct video_device *vfd, | 401 | static void v4l_print_hw_freq_seek(const void *arg, bool write_only) |
331 | struct v4l2_buffer *p) | ||
332 | { | 402 | { |
333 | struct v4l2_timecode *tc = &p->timecode; | 403 | const struct v4l2_hw_freq_seek *p = arg; |
334 | struct v4l2_plane *plane; | 404 | |
405 | pr_cont("tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u\n", | ||
406 | p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing); | ||
407 | } | ||
408 | |||
409 | static void v4l_print_requestbuffers(const void *arg, bool write_only) | ||
410 | { | ||
411 | const struct v4l2_requestbuffers *p = arg; | ||
412 | |||
413 | pr_cont("count=%d, type=%s, memory=%s\n", | ||
414 | p->count, | ||
415 | prt_names(p->type, v4l2_type_names), | ||
416 | prt_names(p->memory, v4l2_memory_names)); | ||
417 | } | ||
418 | |||
419 | static void v4l_print_buffer(const void *arg, bool write_only) | ||
420 | { | ||
421 | const struct v4l2_buffer *p = arg; | ||
422 | const struct v4l2_timecode *tc = &p->timecode; | ||
423 | const struct v4l2_plane *plane; | ||
335 | int i; | 424 | int i; |
336 | 425 | ||
337 | dbgarg(cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, " | 426 | pr_cont("%02ld:%02d:%02d.%08ld index=%d, type=%s, " |
338 | "flags=0x%08d, field=%0d, sequence=%d, memory=%s\n", | 427 | "flags=0x%08x, field=%s, sequence=%d, memory=%s", |
339 | p->timestamp.tv_sec / 3600, | 428 | p->timestamp.tv_sec / 3600, |
340 | (int)(p->timestamp.tv_sec / 60) % 60, | 429 | (int)(p->timestamp.tv_sec / 60) % 60, |
341 | (int)(p->timestamp.tv_sec % 60), | 430 | (int)(p->timestamp.tv_sec % 60), |
342 | (long)p->timestamp.tv_usec, | 431 | (long)p->timestamp.tv_usec, |
343 | p->index, | 432 | p->index, |
344 | prt_names(p->type, v4l2_type_names), | 433 | prt_names(p->type, v4l2_type_names), |
345 | p->flags, p->field, p->sequence, | 434 | p->flags, prt_names(p->field, v4l2_field_names), |
346 | prt_names(p->memory, v4l2_memory_names)); | 435 | p->sequence, prt_names(p->memory, v4l2_memory_names)); |
347 | 436 | ||
348 | if (V4L2_TYPE_IS_MULTIPLANAR(p->type) && p->m.planes) { | 437 | if (V4L2_TYPE_IS_MULTIPLANAR(p->type) && p->m.planes) { |
438 | pr_cont("\n"); | ||
349 | for (i = 0; i < p->length; ++i) { | 439 | for (i = 0; i < p->length; ++i) { |
350 | plane = &p->m.planes[i]; | 440 | plane = &p->m.planes[i]; |
351 | dbgarg2("plane %d: bytesused=%d, data_offset=0x%08x " | 441 | printk(KERN_DEBUG |
352 | "offset/userptr=0x%08lx, length=%d\n", | 442 | "plane %d: bytesused=%d, data_offset=0x%08x " |
443 | "offset/userptr=0x%lx, length=%d\n", | ||
353 | i, plane->bytesused, plane->data_offset, | 444 | i, plane->bytesused, plane->data_offset, |
354 | plane->m.userptr, plane->length); | 445 | plane->m.userptr, plane->length); |
355 | } | 446 | } |
356 | } else { | 447 | } else { |
357 | dbgarg2("bytesused=%d, offset/userptr=0x%08lx, length=%d\n", | 448 | pr_cont("bytesused=%d, offset/userptr=0x%lx, length=%d\n", |
358 | p->bytesused, p->m.userptr, p->length); | 449 | p->bytesused, p->m.userptr, p->length); |
359 | } | 450 | } |
360 | 451 | ||
361 | dbgarg2("timecode=%02d:%02d:%02d type=%d, " | 452 | printk(KERN_DEBUG "timecode=%02d:%02d:%02d type=%d, " |
362 | "flags=0x%08d, frames=%d, userbits=0x%08x\n", | 453 | "flags=0x%08x, frames=%d, userbits=0x%08x\n", |
363 | tc->hours, tc->minutes, tc->seconds, | 454 | tc->hours, tc->minutes, tc->seconds, |
364 | tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); | 455 | tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); |
365 | } | 456 | } |
366 | 457 | ||
367 | static inline void dbgrect(struct video_device *vfd, char *s, | 458 | static void v4l_print_create_buffers(const void *arg, bool write_only) |
368 | struct v4l2_rect *r) | ||
369 | { | 459 | { |
370 | dbgarg2("%sRect start at %dx%d, size=%dx%d\n", s, r->left, r->top, | 460 | const struct v4l2_create_buffers *p = arg; |
371 | r->width, r->height); | 461 | |
372 | }; | 462 | pr_cont("index=%d, count=%d, memory=%s, ", |
463 | p->index, p->count, | ||
464 | prt_names(p->memory, v4l2_memory_names)); | ||
465 | v4l_print_format(&p->format, write_only); | ||
466 | } | ||
373 | 467 | ||
374 | static void dbgtimings(struct video_device *vfd, | 468 | static void v4l_print_streamparm(const void *arg, bool write_only) |
375 | const struct v4l2_dv_timings *p) | ||
376 | { | 469 | { |
470 | const struct v4l2_streamparm *p = arg; | ||
471 | |||
472 | pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); | ||
473 | |||
474 | if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
475 | p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { | ||
476 | const struct v4l2_captureparm *c = &p->parm.capture; | ||
477 | |||
478 | pr_cont(", capability=0x%x, capturemode=0x%x, timeperframe=%d/%d, " | ||
479 | "extendedmode=%d, readbuffers=%d\n", | ||
480 | c->capability, c->capturemode, | ||
481 | c->timeperframe.numerator, c->timeperframe.denominator, | ||
482 | c->extendedmode, c->readbuffers); | ||
483 | } else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT || | ||
484 | p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { | ||
485 | const struct v4l2_outputparm *c = &p->parm.output; | ||
486 | |||
487 | pr_cont(", capability=0x%x, outputmode=0x%x, timeperframe=%d/%d, " | ||
488 | "extendedmode=%d, writebuffers=%d\n", | ||
489 | c->capability, c->outputmode, | ||
490 | c->timeperframe.numerator, c->timeperframe.denominator, | ||
491 | c->extendedmode, c->writebuffers); | ||
492 | } | ||
493 | } | ||
494 | |||
495 | static void v4l_print_queryctrl(const void *arg, bool write_only) | ||
496 | { | ||
497 | const struct v4l2_queryctrl *p = arg; | ||
498 | |||
499 | pr_cont("id=0x%x, type=%d, name=%s, min/max=%d/%d, " | ||
500 | "step=%d, default=%d, flags=0x%08x\n", | ||
501 | p->id, p->type, p->name, | ||
502 | p->minimum, p->maximum, | ||
503 | p->step, p->default_value, p->flags); | ||
504 | } | ||
505 | |||
506 | static void v4l_print_querymenu(const void *arg, bool write_only) | ||
507 | { | ||
508 | const struct v4l2_querymenu *p = arg; | ||
509 | |||
510 | pr_cont("id=0x%x, index=%d\n", p->id, p->index); | ||
511 | } | ||
512 | |||
513 | static void v4l_print_control(const void *arg, bool write_only) | ||
514 | { | ||
515 | const struct v4l2_control *p = arg; | ||
516 | |||
517 | pr_cont("id=0x%x, value=%d\n", p->id, p->value); | ||
518 | } | ||
519 | |||
520 | static void v4l_print_ext_controls(const void *arg, bool write_only) | ||
521 | { | ||
522 | const struct v4l2_ext_controls *p = arg; | ||
523 | int i; | ||
524 | |||
525 | pr_cont("class=0x%x, count=%d, error_idx=%d", | ||
526 | p->ctrl_class, p->count, p->error_idx); | ||
527 | for (i = 0; i < p->count; i++) { | ||
528 | if (p->controls[i].size) | ||
529 | pr_cont(", id/val=0x%x/0x%x", | ||
530 | p->controls[i].id, p->controls[i].value); | ||
531 | else | ||
532 | pr_cont(", id/size=0x%x/%u", | ||
533 | p->controls[i].id, p->controls[i].size); | ||
534 | } | ||
535 | pr_cont("\n"); | ||
536 | } | ||
537 | |||
538 | static void v4l_print_cropcap(const void *arg, bool write_only) | ||
539 | { | ||
540 | const struct v4l2_cropcap *p = arg; | ||
541 | |||
542 | pr_cont("type=%s, bounds wxh=%dx%d, x,y=%d,%d, " | ||
543 | "defrect wxh=%dx%d, x,y=%d,%d\n, " | ||
544 | "pixelaspect %d/%d\n", | ||
545 | prt_names(p->type, v4l2_type_names), | ||
546 | p->bounds.width, p->bounds.height, | ||
547 | p->bounds.left, p->bounds.top, | ||
548 | p->defrect.width, p->defrect.height, | ||
549 | p->defrect.left, p->defrect.top, | ||
550 | p->pixelaspect.numerator, p->pixelaspect.denominator); | ||
551 | } | ||
552 | |||
553 | static void v4l_print_crop(const void *arg, bool write_only) | ||
554 | { | ||
555 | const struct v4l2_crop *p = arg; | ||
556 | |||
557 | pr_cont("type=%s, wxh=%dx%d, x,y=%d,%d\n", | ||
558 | prt_names(p->type, v4l2_type_names), | ||
559 | p->c.width, p->c.height, | ||
560 | p->c.left, p->c.top); | ||
561 | } | ||
562 | |||
563 | static void v4l_print_selection(const void *arg, bool write_only) | ||
564 | { | ||
565 | const struct v4l2_selection *p = arg; | ||
566 | |||
567 | pr_cont("type=%s, target=%d, flags=0x%x, wxh=%dx%d, x,y=%d,%d\n", | ||
568 | prt_names(p->type, v4l2_type_names), | ||
569 | p->target, p->flags, | ||
570 | p->r.width, p->r.height, p->r.left, p->r.top); | ||
571 | } | ||
572 | |||
573 | static void v4l_print_jpegcompression(const void *arg, bool write_only) | ||
574 | { | ||
575 | const struct v4l2_jpegcompression *p = arg; | ||
576 | |||
577 | pr_cont("quality=%d, APPn=%d, APP_len=%d, " | ||
578 | "COM_len=%d, jpeg_markers=0x%x\n", | ||
579 | p->quality, p->APPn, p->APP_len, | ||
580 | p->COM_len, p->jpeg_markers); | ||
581 | } | ||
582 | |||
583 | static void v4l_print_enc_idx(const void *arg, bool write_only) | ||
584 | { | ||
585 | const struct v4l2_enc_idx *p = arg; | ||
586 | |||
587 | pr_cont("entries=%d, entries_cap=%d\n", | ||
588 | p->entries, p->entries_cap); | ||
589 | } | ||
590 | |||
591 | static void v4l_print_encoder_cmd(const void *arg, bool write_only) | ||
592 | { | ||
593 | const struct v4l2_encoder_cmd *p = arg; | ||
594 | |||
595 | pr_cont("cmd=%d, flags=0x%x\n", | ||
596 | p->cmd, p->flags); | ||
597 | } | ||
598 | |||
599 | static void v4l_print_decoder_cmd(const void *arg, bool write_only) | ||
600 | { | ||
601 | const struct v4l2_decoder_cmd *p = arg; | ||
602 | |||
603 | pr_cont("cmd=%d, flags=0x%x\n", p->cmd, p->flags); | ||
604 | |||
605 | if (p->cmd == V4L2_DEC_CMD_START) | ||
606 | pr_info("speed=%d, format=%u\n", | ||
607 | p->start.speed, p->start.format); | ||
608 | else if (p->cmd == V4L2_DEC_CMD_STOP) | ||
609 | pr_info("pts=%llu\n", p->stop.pts); | ||
610 | } | ||
611 | |||
612 | static void v4l_print_dbg_chip_ident(const void *arg, bool write_only) | ||
613 | { | ||
614 | const struct v4l2_dbg_chip_ident *p = arg; | ||
615 | |||
616 | pr_cont("type=%u, ", p->match.type); | ||
617 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) | ||
618 | pr_cont("name=%s, ", p->match.name); | ||
619 | else | ||
620 | pr_cont("addr=%u, ", p->match.addr); | ||
621 | pr_cont("chip_ident=%u, revision=0x%x\n", | ||
622 | p->ident, p->revision); | ||
623 | } | ||
624 | |||
625 | static void v4l_print_dbg_register(const void *arg, bool write_only) | ||
626 | { | ||
627 | const struct v4l2_dbg_register *p = arg; | ||
628 | |||
629 | pr_cont("type=%u, ", p->match.type); | ||
630 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) | ||
631 | pr_cont("name=%s, ", p->match.name); | ||
632 | else | ||
633 | pr_cont("addr=%u, ", p->match.addr); | ||
634 | pr_cont("reg=0x%llx, val=0x%llx\n", | ||
635 | p->reg, p->val); | ||
636 | } | ||
637 | |||
638 | static void v4l_print_dv_enum_presets(const void *arg, bool write_only) | ||
639 | { | ||
640 | const struct v4l2_dv_enum_preset *p = arg; | ||
641 | |||
642 | pr_cont("index=%u, preset=%u, name=%s, width=%u, height=%u\n", | ||
643 | p->index, p->preset, p->name, p->width, p->height); | ||
644 | } | ||
645 | |||
646 | static void v4l_print_dv_preset(const void *arg, bool write_only) | ||
647 | { | ||
648 | const struct v4l2_dv_preset *p = arg; | ||
649 | |||
650 | pr_cont("preset=%u\n", p->preset); | ||
651 | } | ||
652 | |||
653 | static void v4l_print_dv_timings(const void *arg, bool write_only) | ||
654 | { | ||
655 | const struct v4l2_dv_timings *p = arg; | ||
656 | |||
377 | switch (p->type) { | 657 | switch (p->type) { |
378 | case V4L2_DV_BT_656_1120: | 658 | case V4L2_DV_BT_656_1120: |
379 | dbgarg2("bt-656/1120:interlaced=%d," | 659 | pr_cont("type=bt-656/1120, interlaced=%u, " |
380 | " pixelclock=%lld," | 660 | "pixelclock=%llu, " |
381 | " width=%d, height=%d, polarities=%x," | 661 | "width=%u, height=%u, polarities=0x%x, " |
382 | " hfrontporch=%d, hsync=%d," | 662 | "hfrontporch=%u, hsync=%u, " |
383 | " hbackporch=%d, vfrontporch=%d," | 663 | "hbackporch=%u, vfrontporch=%u, " |
384 | " vsync=%d, vbackporch=%d," | 664 | "vsync=%u, vbackporch=%u, " |
385 | " il_vfrontporch=%d, il_vsync=%d," | 665 | "il_vfrontporch=%u, il_vsync=%u, " |
386 | " il_vbackporch=%d, standards=%x, flags=%x\n", | 666 | "il_vbackporch=%u, standards=0x%x, flags=0x%x\n", |
387 | p->bt.interlaced, p->bt.pixelclock, | 667 | p->bt.interlaced, p->bt.pixelclock, |
388 | p->bt.width, p->bt.height, | 668 | p->bt.width, p->bt.height, |
389 | p->bt.polarities, p->bt.hfrontporch, | 669 | p->bt.polarities, p->bt.hfrontporch, |
@@ -394,67 +674,173 @@ static void dbgtimings(struct video_device *vfd, | |||
394 | p->bt.standards, p->bt.flags); | 674 | p->bt.standards, p->bt.flags); |
395 | break; | 675 | break; |
396 | default: | 676 | default: |
397 | dbgarg2("Unknown type %d!\n", p->type); | 677 | pr_cont("type=%d\n", p->type); |
398 | break; | 678 | break; |
399 | } | 679 | } |
400 | } | 680 | } |
401 | 681 | ||
402 | static inline void v4l_print_pix_fmt(struct video_device *vfd, | 682 | static void v4l_print_enum_dv_timings(const void *arg, bool write_only) |
403 | struct v4l2_pix_format *fmt) | ||
404 | { | 683 | { |
405 | dbgarg2("width=%d, height=%d, format=%c%c%c%c, field=%s, " | 684 | const struct v4l2_enum_dv_timings *p = arg; |
406 | "bytesperline=%d sizeimage=%d, colorspace=%d\n", | 685 | |
407 | fmt->width, fmt->height, | 686 | pr_cont("index=%u, ", p->index); |
408 | (fmt->pixelformat & 0xff), | 687 | v4l_print_dv_timings(&p->timings, write_only); |
409 | (fmt->pixelformat >> 8) & 0xff, | 688 | } |
410 | (fmt->pixelformat >> 16) & 0xff, | ||
411 | (fmt->pixelformat >> 24) & 0xff, | ||
412 | prt_names(fmt->field, v4l2_field_names), | ||
413 | fmt->bytesperline, fmt->sizeimage, fmt->colorspace); | ||
414 | }; | ||
415 | 689 | ||
416 | static inline void v4l_print_pix_fmt_mplane(struct video_device *vfd, | 690 | static void v4l_print_dv_timings_cap(const void *arg, bool write_only) |
417 | struct v4l2_pix_format_mplane *fmt) | ||
418 | { | 691 | { |
419 | int i; | 692 | const struct v4l2_dv_timings_cap *p = arg; |
693 | |||
694 | switch (p->type) { | ||
695 | case V4L2_DV_BT_656_1120: | ||
696 | pr_cont("type=bt-656/1120, width=%u-%u, height=%u-%u, " | ||
697 | "pixelclock=%llu-%llu, standards=0x%x, capabilities=0x%x\n", | ||
698 | p->bt.min_width, p->bt.max_width, | ||
699 | p->bt.min_height, p->bt.max_height, | ||
700 | p->bt.min_pixelclock, p->bt.max_pixelclock, | ||
701 | p->bt.standards, p->bt.capabilities); | ||
702 | break; | ||
703 | default: | ||
704 | pr_cont("type=%u\n", p->type); | ||
705 | break; | ||
706 | } | ||
707 | } | ||
420 | 708 | ||
421 | dbgarg2("width=%d, height=%d, format=%c%c%c%c, field=%s, " | 709 | static void v4l_print_frmsizeenum(const void *arg, bool write_only) |
422 | "colorspace=%d, num_planes=%d\n", | 710 | { |
423 | fmt->width, fmt->height, | 711 | const struct v4l2_frmsizeenum *p = arg; |
424 | (fmt->pixelformat & 0xff), | ||
425 | (fmt->pixelformat >> 8) & 0xff, | ||
426 | (fmt->pixelformat >> 16) & 0xff, | ||
427 | (fmt->pixelformat >> 24) & 0xff, | ||
428 | prt_names(fmt->field, v4l2_field_names), | ||
429 | fmt->colorspace, fmt->num_planes); | ||
430 | 712 | ||
431 | for (i = 0; i < fmt->num_planes; ++i) | 713 | pr_cont("index=%u, pixelformat=%c%c%c%c, type=%u", |
432 | dbgarg2("plane %d: bytesperline=%d sizeimage=%d\n", i, | 714 | p->index, |
433 | fmt->plane_fmt[i].bytesperline, | 715 | (p->pixel_format & 0xff), |
434 | fmt->plane_fmt[i].sizeimage); | 716 | (p->pixel_format >> 8) & 0xff, |
717 | (p->pixel_format >> 16) & 0xff, | ||
718 | (p->pixel_format >> 24) & 0xff, | ||
719 | p->type); | ||
720 | switch (p->type) { | ||
721 | case V4L2_FRMSIZE_TYPE_DISCRETE: | ||
722 | pr_cont(" wxh=%ux%u\n", | ||
723 | p->discrete.width, p->discrete.height); | ||
724 | break; | ||
725 | case V4L2_FRMSIZE_TYPE_STEPWISE: | ||
726 | pr_cont(" min=%ux%u, max=%ux%u, step=%ux%u\n", | ||
727 | p->stepwise.min_width, p->stepwise.min_height, | ||
728 | p->stepwise.step_width, p->stepwise.step_height, | ||
729 | p->stepwise.max_width, p->stepwise.max_height); | ||
730 | break; | ||
731 | case V4L2_FRMSIZE_TYPE_CONTINUOUS: | ||
732 | /* fall through */ | ||
733 | default: | ||
734 | pr_cont("\n"); | ||
735 | break; | ||
736 | } | ||
435 | } | 737 | } |
436 | 738 | ||
437 | static inline void v4l_print_ext_ctrls(unsigned int cmd, | 739 | static void v4l_print_frmivalenum(const void *arg, bool write_only) |
438 | struct video_device *vfd, struct v4l2_ext_controls *c, int show_vals) | ||
439 | { | 740 | { |
440 | __u32 i; | 741 | const struct v4l2_frmivalenum *p = arg; |
441 | 742 | ||
442 | if (!(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) | 743 | pr_cont("index=%u, pixelformat=%c%c%c%c, wxh=%ux%u, type=%u", |
443 | return; | 744 | p->index, |
444 | dbgarg(cmd, ""); | 745 | (p->pixel_format & 0xff), |
445 | printk(KERN_CONT "class=0x%x", c->ctrl_class); | 746 | (p->pixel_format >> 8) & 0xff, |
446 | for (i = 0; i < c->count; i++) { | 747 | (p->pixel_format >> 16) & 0xff, |
447 | if (show_vals && !c->controls[i].size) | 748 | (p->pixel_format >> 24) & 0xff, |
448 | printk(KERN_CONT " id/val=0x%x/0x%x", | 749 | p->width, p->height, p->type); |
449 | c->controls[i].id, c->controls[i].value); | 750 | switch (p->type) { |
751 | case V4L2_FRMIVAL_TYPE_DISCRETE: | ||
752 | pr_cont(" fps=%d/%d\n", | ||
753 | p->discrete.numerator, | ||
754 | p->discrete.denominator); | ||
755 | break; | ||
756 | case V4L2_FRMIVAL_TYPE_STEPWISE: | ||
757 | pr_cont(" min=%d/%d, max=%d/%d, step=%d/%d\n", | ||
758 | p->stepwise.min.numerator, | ||
759 | p->stepwise.min.denominator, | ||
760 | p->stepwise.max.numerator, | ||
761 | p->stepwise.max.denominator, | ||
762 | p->stepwise.step.numerator, | ||
763 | p->stepwise.step.denominator); | ||
764 | break; | ||
765 | case V4L2_FRMIVAL_TYPE_CONTINUOUS: | ||
766 | /* fall through */ | ||
767 | default: | ||
768 | pr_cont("\n"); | ||
769 | break; | ||
770 | } | ||
771 | } | ||
772 | |||
773 | static void v4l_print_event(const void *arg, bool write_only) | ||
774 | { | ||
775 | const struct v4l2_event *p = arg; | ||
776 | const struct v4l2_event_ctrl *c; | ||
777 | |||
778 | pr_cont("type=0x%x, pending=%u, sequence=%u, id=%u, " | ||
779 | "timestamp=%lu.%9.9lu\n", | ||
780 | p->type, p->pending, p->sequence, p->id, | ||
781 | p->timestamp.tv_sec, p->timestamp.tv_nsec); | ||
782 | switch (p->type) { | ||
783 | case V4L2_EVENT_VSYNC: | ||
784 | printk(KERN_DEBUG "field=%s\n", | ||
785 | prt_names(p->u.vsync.field, v4l2_field_names)); | ||
786 | break; | ||
787 | case V4L2_EVENT_CTRL: | ||
788 | c = &p->u.ctrl; | ||
789 | printk(KERN_DEBUG "changes=0x%x, type=%u, ", | ||
790 | c->changes, c->type); | ||
791 | if (c->type == V4L2_CTRL_TYPE_INTEGER64) | ||
792 | pr_cont("value64=%lld, ", c->value64); | ||
450 | else | 793 | else |
451 | printk(KERN_CONT " id=0x%x,size=%u", | 794 | pr_cont("value=%d, ", c->value); |
452 | c->controls[i].id, c->controls[i].size); | 795 | pr_cont("flags=0x%x, minimum=%d, maximum=%d, step=%d," |
796 | " default_value=%d\n", | ||
797 | c->flags, c->minimum, c->maximum, | ||
798 | c->step, c->default_value); | ||
799 | break; | ||
800 | case V4L2_EVENT_FRAME_SYNC: | ||
801 | pr_cont("frame_sequence=%u\n", | ||
802 | p->u.frame_sync.frame_sequence); | ||
803 | break; | ||
453 | } | 804 | } |
454 | printk(KERN_CONT "\n"); | 805 | } |
455 | }; | ||
456 | 806 | ||
457 | static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) | 807 | static void v4l_print_event_subscription(const void *arg, bool write_only) |
808 | { | ||
809 | const struct v4l2_event_subscription *p = arg; | ||
810 | |||
811 | pr_cont("type=0x%x, id=0x%x, flags=0x%x\n", | ||
812 | p->type, p->id, p->flags); | ||
813 | } | ||
814 | |||
815 | static void v4l_print_sliced_vbi_cap(const void *arg, bool write_only) | ||
816 | { | ||
817 | const struct v4l2_sliced_vbi_cap *p = arg; | ||
818 | int i; | ||
819 | |||
820 | pr_cont("type=%s, service_set=0x%08x\n", | ||
821 | prt_names(p->type, v4l2_type_names), p->service_set); | ||
822 | for (i = 0; i < 24; i++) | ||
823 | printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i, | ||
824 | p->service_lines[0][i], | ||
825 | p->service_lines[1][i]); | ||
826 | } | ||
827 | |||
828 | static void v4l_print_u32(const void *arg, bool write_only) | ||
829 | { | ||
830 | pr_cont("value=%u\n", *(const u32 *)arg); | ||
831 | } | ||
832 | |||
833 | static void v4l_print_newline(const void *arg, bool write_only) | ||
834 | { | ||
835 | pr_cont("\n"); | ||
836 | } | ||
837 | |||
838 | static void v4l_print_default(const void *arg, bool write_only) | ||
839 | { | ||
840 | pr_cont("driver-specific ioctl\n"); | ||
841 | } | ||
842 | |||
843 | static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) | ||
458 | { | 844 | { |
459 | __u32 i; | 845 | __u32 i; |
460 | 846 | ||
@@ -536,1615 +922,1159 @@ static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type) | |||
536 | return -EINVAL; | 922 | return -EINVAL; |
537 | } | 923 | } |
538 | 924 | ||
539 | static long __video_do_ioctl(struct file *file, | 925 | static int v4l_querycap(const struct v4l2_ioctl_ops *ops, |
540 | unsigned int cmd, void *arg) | 926 | struct file *file, void *fh, void *arg) |
541 | { | 927 | { |
542 | struct video_device *vfd = video_devdata(file); | 928 | struct v4l2_capability *cap = (struct v4l2_capability *)arg; |
543 | const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; | ||
544 | void *fh = file->private_data; | ||
545 | struct v4l2_fh *vfh = NULL; | ||
546 | int use_fh_prio = 0; | ||
547 | long ret = -ENOTTY; | ||
548 | 929 | ||
549 | if (ops == NULL) { | 930 | cap->version = LINUX_VERSION_CODE; |
550 | printk(KERN_WARNING "videodev: \"%s\" has no ioctl_ops.\n", | 931 | return ops->vidioc_querycap(file, fh, cap); |
551 | vfd->name); | 932 | } |
552 | return ret; | ||
553 | } | ||
554 | |||
555 | if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { | ||
556 | vfh = file->private_data; | ||
557 | use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | ||
558 | } | ||
559 | 933 | ||
560 | if (v4l2_is_known_ioctl(cmd)) { | 934 | static int v4l_s_input(const struct v4l2_ioctl_ops *ops, |
561 | struct v4l2_ioctl_info *info = &v4l2_ioctls[_IOC_NR(cmd)]; | 935 | struct file *file, void *fh, void *arg) |
936 | { | ||
937 | return ops->vidioc_s_input(file, fh, *(unsigned int *)arg); | ||
938 | } | ||
562 | 939 | ||
563 | if (!test_bit(_IOC_NR(cmd), vfd->valid_ioctls) && | 940 | static int v4l_s_output(const struct v4l2_ioctl_ops *ops, |
564 | !((info->flags & INFO_FL_CTRL) && vfh && vfh->ctrl_handler)) | 941 | struct file *file, void *fh, void *arg) |
565 | return -ENOTTY; | 942 | { |
943 | return ops->vidioc_s_output(file, fh, *(unsigned int *)arg); | ||
944 | } | ||
566 | 945 | ||
567 | if (use_fh_prio && (info->flags & INFO_FL_PRIO)) { | 946 | static int v4l_g_priority(const struct v4l2_ioctl_ops *ops, |
568 | ret = v4l2_prio_check(vfd->prio, vfh->prio); | 947 | struct file *file, void *fh, void *arg) |
569 | if (ret) | 948 | { |
570 | return ret; | 949 | struct video_device *vfd; |
571 | } | 950 | u32 *p = arg; |
572 | } | ||
573 | 951 | ||
574 | if ((vfd->debug & V4L2_DEBUG_IOCTL) && | 952 | if (ops->vidioc_g_priority) |
575 | !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { | 953 | return ops->vidioc_g_priority(file, fh, arg); |
576 | v4l_print_ioctl(vfd->name, cmd); | 954 | vfd = video_devdata(file); |
577 | printk(KERN_CONT "\n"); | 955 | *p = v4l2_prio_max(&vfd->v4l2_dev->prio); |
578 | } | 956 | return 0; |
957 | } | ||
579 | 958 | ||
580 | switch (cmd) { | 959 | static int v4l_s_priority(const struct v4l2_ioctl_ops *ops, |
960 | struct file *file, void *fh, void *arg) | ||
961 | { | ||
962 | struct video_device *vfd; | ||
963 | struct v4l2_fh *vfh; | ||
964 | u32 *p = arg; | ||
965 | |||
966 | if (ops->vidioc_s_priority) | ||
967 | return ops->vidioc_s_priority(file, fh, *p); | ||
968 | vfd = video_devdata(file); | ||
969 | vfh = file->private_data; | ||
970 | return v4l2_prio_change(&vfd->v4l2_dev->prio, &vfh->prio, *p); | ||
971 | } | ||
581 | 972 | ||
582 | /* --- capabilities ------------------------------------------ */ | 973 | static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, |
583 | case VIDIOC_QUERYCAP: | 974 | struct file *file, void *fh, void *arg) |
584 | { | 975 | { |
585 | struct v4l2_capability *cap = (struct v4l2_capability *)arg; | 976 | struct v4l2_input *p = arg; |
586 | |||
587 | cap->version = LINUX_VERSION_CODE; | ||
588 | ret = ops->vidioc_querycap(file, fh, cap); | ||
589 | if (!ret) | ||
590 | dbgarg(cmd, "driver=%s, card=%s, bus=%s, " | ||
591 | "version=0x%08x, " | ||
592 | "capabilities=0x%08x, " | ||
593 | "device_caps=0x%08x\n", | ||
594 | cap->driver, cap->card, cap->bus_info, | ||
595 | cap->version, | ||
596 | cap->capabilities, | ||
597 | cap->device_caps); | ||
598 | break; | ||
599 | } | ||
600 | 977 | ||
601 | /* --- priority ------------------------------------------ */ | 978 | /* |
602 | case VIDIOC_G_PRIORITY: | 979 | * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & |
603 | { | 980 | * CAP_STD here based on ioctl handler provided by the |
604 | enum v4l2_priority *p = arg; | 981 | * driver. If the driver doesn't support these |
982 | * for a specific input, it must override these flags. | ||
983 | */ | ||
984 | if (ops->vidioc_s_std) | ||
985 | p->capabilities |= V4L2_IN_CAP_STD; | ||
986 | if (ops->vidioc_s_dv_preset) | ||
987 | p->capabilities |= V4L2_IN_CAP_PRESETS; | ||
988 | if (ops->vidioc_s_dv_timings) | ||
989 | p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS; | ||
990 | |||
991 | return ops->vidioc_enum_input(file, fh, p); | ||
992 | } | ||
605 | 993 | ||
606 | if (ops->vidioc_g_priority) { | 994 | static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops, |
607 | ret = ops->vidioc_g_priority(file, fh, p); | 995 | struct file *file, void *fh, void *arg) |
608 | } else if (use_fh_prio) { | 996 | { |
609 | *p = v4l2_prio_max(&vfd->v4l2_dev->prio); | 997 | struct v4l2_output *p = arg; |
610 | ret = 0; | ||
611 | } | ||
612 | if (!ret) | ||
613 | dbgarg(cmd, "priority is %d\n", *p); | ||
614 | break; | ||
615 | } | ||
616 | case VIDIOC_S_PRIORITY: | ||
617 | { | ||
618 | enum v4l2_priority *p = arg; | ||
619 | 998 | ||
620 | dbgarg(cmd, "setting priority to %d\n", *p); | 999 | /* |
621 | if (ops->vidioc_s_priority) | 1000 | * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & |
622 | ret = ops->vidioc_s_priority(file, fh, *p); | 1001 | * CAP_STD here based on ioctl handler provided by the |
623 | else | 1002 | * driver. If the driver doesn't support these |
624 | ret = v4l2_prio_change(&vfd->v4l2_dev->prio, | 1003 | * for a specific output, it must override these flags. |
625 | &vfh->prio, *p); | 1004 | */ |
626 | break; | 1005 | if (ops->vidioc_s_std) |
627 | } | 1006 | p->capabilities |= V4L2_OUT_CAP_STD; |
1007 | if (ops->vidioc_s_dv_preset) | ||
1008 | p->capabilities |= V4L2_OUT_CAP_PRESETS; | ||
1009 | if (ops->vidioc_s_dv_timings) | ||
1010 | p->capabilities |= V4L2_OUT_CAP_CUSTOM_TIMINGS; | ||
1011 | |||
1012 | return ops->vidioc_enum_output(file, fh, p); | ||
1013 | } | ||
628 | 1014 | ||
629 | /* --- capture ioctls ---------------------------------------- */ | 1015 | static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, |
630 | case VIDIOC_ENUM_FMT: | 1016 | struct file *file, void *fh, void *arg) |
631 | { | 1017 | { |
632 | struct v4l2_fmtdesc *f = arg; | 1018 | struct v4l2_fmtdesc *p = arg; |
633 | 1019 | ||
634 | ret = -EINVAL; | 1020 | switch (p->type) { |
635 | switch (f->type) { | 1021 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
636 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1022 | if (unlikely(!ops->vidioc_enum_fmt_vid_cap)) |
637 | if (likely(ops->vidioc_enum_fmt_vid_cap)) | ||
638 | ret = ops->vidioc_enum_fmt_vid_cap(file, fh, f); | ||
639 | break; | ||
640 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | ||
641 | if (likely(ops->vidioc_enum_fmt_vid_cap_mplane)) | ||
642 | ret = ops->vidioc_enum_fmt_vid_cap_mplane(file, | ||
643 | fh, f); | ||
644 | break; | 1023 | break; |
645 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1024 | return ops->vidioc_enum_fmt_vid_cap(file, fh, arg); |
646 | if (likely(ops->vidioc_enum_fmt_vid_overlay)) | 1025 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
647 | ret = ops->vidioc_enum_fmt_vid_overlay(file, | 1026 | if (unlikely(!ops->vidioc_enum_fmt_vid_cap_mplane)) |
648 | fh, f); | ||
649 | break; | 1027 | break; |
650 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1028 | return ops->vidioc_enum_fmt_vid_cap_mplane(file, fh, arg); |
651 | if (likely(ops->vidioc_enum_fmt_vid_out)) | 1029 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
652 | ret = ops->vidioc_enum_fmt_vid_out(file, fh, f); | 1030 | if (unlikely(!ops->vidioc_enum_fmt_vid_overlay)) |
653 | break; | 1031 | break; |
654 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 1032 | return ops->vidioc_enum_fmt_vid_overlay(file, fh, arg); |
655 | if (likely(ops->vidioc_enum_fmt_vid_out_mplane)) | 1033 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
656 | ret = ops->vidioc_enum_fmt_vid_out_mplane(file, | 1034 | if (unlikely(!ops->vidioc_enum_fmt_vid_out)) |
657 | fh, f); | ||
658 | break; | 1035 | break; |
659 | case V4L2_BUF_TYPE_PRIVATE: | 1036 | return ops->vidioc_enum_fmt_vid_out(file, fh, arg); |
660 | if (likely(ops->vidioc_enum_fmt_type_private)) | 1037 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
661 | ret = ops->vidioc_enum_fmt_type_private(file, | 1038 | if (unlikely(!ops->vidioc_enum_fmt_vid_out_mplane)) |
662 | fh, f); | ||
663 | break; | 1039 | break; |
664 | default: | 1040 | return ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg); |
1041 | case V4L2_BUF_TYPE_PRIVATE: | ||
1042 | if (unlikely(!ops->vidioc_enum_fmt_type_private)) | ||
665 | break; | 1043 | break; |
666 | } | 1044 | return ops->vidioc_enum_fmt_type_private(file, fh, arg); |
667 | if (likely(!ret)) | ||
668 | dbgarg(cmd, "index=%d, type=%d, flags=%d, " | ||
669 | "pixelformat=%c%c%c%c, description='%s'\n", | ||
670 | f->index, f->type, f->flags, | ||
671 | (f->pixelformat & 0xff), | ||
672 | (f->pixelformat >> 8) & 0xff, | ||
673 | (f->pixelformat >> 16) & 0xff, | ||
674 | (f->pixelformat >> 24) & 0xff, | ||
675 | f->description); | ||
676 | break; | ||
677 | } | 1045 | } |
678 | case VIDIOC_G_FMT: | 1046 | return -EINVAL; |
679 | { | 1047 | } |
680 | struct v4l2_format *f = (struct v4l2_format *)arg; | 1048 | |
681 | 1049 | static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, | |
682 | /* FIXME: Should be one dump per type */ | 1050 | struct file *file, void *fh, void *arg) |
683 | dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names)); | 1051 | { |
684 | 1052 | struct v4l2_format *p = arg; | |
685 | ret = -EINVAL; | 1053 | |
686 | switch (f->type) { | 1054 | switch (p->type) { |
687 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1055 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
688 | if (ops->vidioc_g_fmt_vid_cap) | 1056 | if (unlikely(!ops->vidioc_g_fmt_vid_cap)) |
689 | ret = ops->vidioc_g_fmt_vid_cap(file, fh, f); | ||
690 | if (!ret) | ||
691 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
692 | break; | 1057 | break; |
693 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | 1058 | return ops->vidioc_g_fmt_vid_cap(file, fh, arg); |
694 | if (ops->vidioc_g_fmt_vid_cap_mplane) | 1059 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
695 | ret = ops->vidioc_g_fmt_vid_cap_mplane(file, | 1060 | if (unlikely(!ops->vidioc_g_fmt_vid_cap_mplane)) |
696 | fh, f); | ||
697 | if (!ret) | ||
698 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | ||
699 | break; | 1061 | break; |
700 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1062 | return ops->vidioc_g_fmt_vid_cap_mplane(file, fh, arg); |
701 | if (likely(ops->vidioc_g_fmt_vid_overlay)) | 1063 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
702 | ret = ops->vidioc_g_fmt_vid_overlay(file, | 1064 | if (unlikely(!ops->vidioc_g_fmt_vid_overlay)) |
703 | fh, f); | ||
704 | break; | 1065 | break; |
705 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1066 | return ops->vidioc_g_fmt_vid_overlay(file, fh, arg); |
706 | if (ops->vidioc_g_fmt_vid_out) | 1067 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
707 | ret = ops->vidioc_g_fmt_vid_out(file, fh, f); | 1068 | if (unlikely(!ops->vidioc_g_fmt_vid_out)) |
708 | if (!ret) | ||
709 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
710 | break; | 1069 | break; |
711 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 1070 | return ops->vidioc_g_fmt_vid_out(file, fh, arg); |
712 | if (ops->vidioc_g_fmt_vid_out_mplane) | 1071 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
713 | ret = ops->vidioc_g_fmt_vid_out_mplane(file, | 1072 | if (unlikely(!ops->vidioc_g_fmt_vid_out_mplane)) |
714 | fh, f); | ||
715 | if (!ret) | ||
716 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | ||
717 | break; | 1073 | break; |
718 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: | 1074 | return ops->vidioc_g_fmt_vid_out_mplane(file, fh, arg); |
719 | if (likely(ops->vidioc_g_fmt_vid_out_overlay)) | 1075 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
720 | ret = ops->vidioc_g_fmt_vid_out_overlay(file, | 1076 | if (unlikely(!ops->vidioc_g_fmt_vid_out_overlay)) |
721 | fh, f); | ||
722 | break; | 1077 | break; |
723 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1078 | return ops->vidioc_g_fmt_vid_out_overlay(file, fh, arg); |
724 | if (likely(ops->vidioc_g_fmt_vbi_cap)) | 1079 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
725 | ret = ops->vidioc_g_fmt_vbi_cap(file, fh, f); | 1080 | if (unlikely(!ops->vidioc_g_fmt_vbi_cap)) |
726 | break; | 1081 | break; |
727 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 1082 | return ops->vidioc_g_fmt_vbi_cap(file, fh, arg); |
728 | if (likely(ops->vidioc_g_fmt_vbi_out)) | 1083 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
729 | ret = ops->vidioc_g_fmt_vbi_out(file, fh, f); | 1084 | if (unlikely(!ops->vidioc_g_fmt_vbi_out)) |
730 | break; | 1085 | break; |
731 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | 1086 | return ops->vidioc_g_fmt_vbi_out(file, fh, arg); |
732 | if (likely(ops->vidioc_g_fmt_sliced_vbi_cap)) | 1087 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
733 | ret = ops->vidioc_g_fmt_sliced_vbi_cap(file, | 1088 | if (unlikely(!ops->vidioc_g_fmt_sliced_vbi_cap)) |
734 | fh, f); | ||
735 | break; | 1089 | break; |
736 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | 1090 | return ops->vidioc_g_fmt_sliced_vbi_cap(file, fh, arg); |
737 | if (likely(ops->vidioc_g_fmt_sliced_vbi_out)) | 1091 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
738 | ret = ops->vidioc_g_fmt_sliced_vbi_out(file, | 1092 | if (unlikely(!ops->vidioc_g_fmt_sliced_vbi_out)) |
739 | fh, f); | ||
740 | break; | 1093 | break; |
741 | case V4L2_BUF_TYPE_PRIVATE: | 1094 | return ops->vidioc_g_fmt_sliced_vbi_out(file, fh, arg); |
742 | if (likely(ops->vidioc_g_fmt_type_private)) | 1095 | case V4L2_BUF_TYPE_PRIVATE: |
743 | ret = ops->vidioc_g_fmt_type_private(file, | 1096 | if (unlikely(!ops->vidioc_g_fmt_type_private)) |
744 | fh, f); | ||
745 | break; | 1097 | break; |
746 | } | 1098 | return ops->vidioc_g_fmt_type_private(file, fh, arg); |
747 | break; | ||
748 | } | 1099 | } |
749 | case VIDIOC_S_FMT: | 1100 | return -EINVAL; |
750 | { | 1101 | } |
751 | struct v4l2_format *f = (struct v4l2_format *)arg; | ||
752 | |||
753 | ret = -EINVAL; | ||
754 | 1102 | ||
755 | /* FIXME: Should be one dump per type */ | 1103 | static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, |
756 | dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names)); | 1104 | struct file *file, void *fh, void *arg) |
1105 | { | ||
1106 | struct v4l2_format *p = arg; | ||
757 | 1107 | ||
758 | switch (f->type) { | 1108 | switch (p->type) { |
759 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1109 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
760 | CLEAR_AFTER_FIELD(f, fmt.pix); | 1110 | if (unlikely(!ops->vidioc_s_fmt_vid_cap)) |
761 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
762 | if (ops->vidioc_s_fmt_vid_cap) | ||
763 | ret = ops->vidioc_s_fmt_vid_cap(file, fh, f); | ||
764 | break; | 1111 | break; |
765 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | 1112 | CLEAR_AFTER_FIELD(p, fmt.pix); |
766 | CLEAR_AFTER_FIELD(f, fmt.pix_mp); | 1113 | return ops->vidioc_s_fmt_vid_cap(file, fh, arg); |
767 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | 1114 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
768 | if (ops->vidioc_s_fmt_vid_cap_mplane) | 1115 | if (unlikely(!ops->vidioc_s_fmt_vid_cap_mplane)) |
769 | ret = ops->vidioc_s_fmt_vid_cap_mplane(file, | ||
770 | fh, f); | ||
771 | break; | 1116 | break; |
772 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1117 | CLEAR_AFTER_FIELD(p, fmt.pix_mp); |
773 | CLEAR_AFTER_FIELD(f, fmt.win); | 1118 | return ops->vidioc_s_fmt_vid_cap_mplane(file, fh, arg); |
774 | if (ops->vidioc_s_fmt_vid_overlay) | 1119 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
775 | ret = ops->vidioc_s_fmt_vid_overlay(file, | 1120 | if (unlikely(!ops->vidioc_s_fmt_vid_overlay)) |
776 | fh, f); | ||
777 | break; | 1121 | break; |
778 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1122 | CLEAR_AFTER_FIELD(p, fmt.win); |
779 | CLEAR_AFTER_FIELD(f, fmt.pix); | 1123 | return ops->vidioc_s_fmt_vid_overlay(file, fh, arg); |
780 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | 1124 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
781 | if (ops->vidioc_s_fmt_vid_out) | 1125 | if (unlikely(!ops->vidioc_s_fmt_vid_out)) |
782 | ret = ops->vidioc_s_fmt_vid_out(file, fh, f); | ||
783 | break; | 1126 | break; |
784 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 1127 | CLEAR_AFTER_FIELD(p, fmt.pix); |
785 | CLEAR_AFTER_FIELD(f, fmt.pix_mp); | 1128 | return ops->vidioc_s_fmt_vid_out(file, fh, arg); |
786 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | 1129 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
787 | if (ops->vidioc_s_fmt_vid_out_mplane) | 1130 | if (unlikely(!ops->vidioc_s_fmt_vid_out_mplane)) |
788 | ret = ops->vidioc_s_fmt_vid_out_mplane(file, | ||
789 | fh, f); | ||
790 | break; | 1131 | break; |
791 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: | 1132 | CLEAR_AFTER_FIELD(p, fmt.pix_mp); |
792 | CLEAR_AFTER_FIELD(f, fmt.win); | 1133 | return ops->vidioc_s_fmt_vid_out_mplane(file, fh, arg); |
793 | if (ops->vidioc_s_fmt_vid_out_overlay) | 1134 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
794 | ret = ops->vidioc_s_fmt_vid_out_overlay(file, | 1135 | if (unlikely(!ops->vidioc_s_fmt_vid_out_overlay)) |
795 | fh, f); | ||
796 | break; | 1136 | break; |
797 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1137 | CLEAR_AFTER_FIELD(p, fmt.win); |
798 | CLEAR_AFTER_FIELD(f, fmt.vbi); | 1138 | return ops->vidioc_s_fmt_vid_out_overlay(file, fh, arg); |
799 | if (likely(ops->vidioc_s_fmt_vbi_cap)) | 1139 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
800 | ret = ops->vidioc_s_fmt_vbi_cap(file, fh, f); | 1140 | if (unlikely(!ops->vidioc_s_fmt_vbi_cap)) |
801 | break; | 1141 | break; |
802 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 1142 | CLEAR_AFTER_FIELD(p, fmt.vbi); |
803 | CLEAR_AFTER_FIELD(f, fmt.vbi); | 1143 | return ops->vidioc_s_fmt_vbi_cap(file, fh, arg); |
804 | if (likely(ops->vidioc_s_fmt_vbi_out)) | 1144 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
805 | ret = ops->vidioc_s_fmt_vbi_out(file, fh, f); | 1145 | if (unlikely(!ops->vidioc_s_fmt_vbi_out)) |
806 | break; | 1146 | break; |
807 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | 1147 | CLEAR_AFTER_FIELD(p, fmt.vbi); |
808 | CLEAR_AFTER_FIELD(f, fmt.sliced); | 1148 | return ops->vidioc_s_fmt_vbi_out(file, fh, arg); |
809 | if (likely(ops->vidioc_s_fmt_sliced_vbi_cap)) | 1149 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
810 | ret = ops->vidioc_s_fmt_sliced_vbi_cap(file, | 1150 | if (unlikely(!ops->vidioc_s_fmt_sliced_vbi_cap)) |
811 | fh, f); | ||
812 | break; | 1151 | break; |
813 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | 1152 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
814 | CLEAR_AFTER_FIELD(f, fmt.sliced); | 1153 | return ops->vidioc_s_fmt_sliced_vbi_cap(file, fh, arg); |
815 | if (likely(ops->vidioc_s_fmt_sliced_vbi_out)) | 1154 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
816 | ret = ops->vidioc_s_fmt_sliced_vbi_out(file, | 1155 | if (unlikely(!ops->vidioc_s_fmt_sliced_vbi_out)) |
817 | fh, f); | ||
818 | |||
819 | break; | 1156 | break; |
820 | case V4L2_BUF_TYPE_PRIVATE: | 1157 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
821 | /* CLEAR_AFTER_FIELD(f, fmt.raw_data); <- does nothing */ | 1158 | return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg); |
822 | if (likely(ops->vidioc_s_fmt_type_private)) | 1159 | case V4L2_BUF_TYPE_PRIVATE: |
823 | ret = ops->vidioc_s_fmt_type_private(file, | 1160 | if (unlikely(!ops->vidioc_s_fmt_type_private)) |
824 | fh, f); | ||
825 | break; | 1161 | break; |
826 | } | 1162 | return ops->vidioc_s_fmt_type_private(file, fh, arg); |
827 | break; | ||
828 | } | 1163 | } |
829 | case VIDIOC_TRY_FMT: | 1164 | return -EINVAL; |
830 | { | 1165 | } |
831 | struct v4l2_format *f = (struct v4l2_format *)arg; | 1166 | |
832 | 1167 | static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, | |
833 | /* FIXME: Should be one dump per type */ | 1168 | struct file *file, void *fh, void *arg) |
834 | dbgarg(cmd, "type=%s\n", prt_names(f->type, | 1169 | { |
835 | v4l2_type_names)); | 1170 | struct v4l2_format *p = arg; |
836 | ret = -EINVAL; | 1171 | |
837 | switch (f->type) { | 1172 | switch (p->type) { |
838 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1173 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
839 | CLEAR_AFTER_FIELD(f, fmt.pix); | 1174 | if (unlikely(!ops->vidioc_try_fmt_vid_cap)) |
840 | if (ops->vidioc_try_fmt_vid_cap) | ||
841 | ret = ops->vidioc_try_fmt_vid_cap(file, fh, f); | ||
842 | if (!ret) | ||
843 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
844 | break; | 1175 | break; |
845 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | 1176 | CLEAR_AFTER_FIELD(p, fmt.pix); |
846 | CLEAR_AFTER_FIELD(f, fmt.pix_mp); | 1177 | return ops->vidioc_try_fmt_vid_cap(file, fh, arg); |
847 | if (ops->vidioc_try_fmt_vid_cap_mplane) | 1178 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
848 | ret = ops->vidioc_try_fmt_vid_cap_mplane(file, | 1179 | if (unlikely(!ops->vidioc_try_fmt_vid_cap_mplane)) |
849 | fh, f); | ||
850 | if (!ret) | ||
851 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | ||
852 | break; | 1180 | break; |
853 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1181 | CLEAR_AFTER_FIELD(p, fmt.pix_mp); |
854 | CLEAR_AFTER_FIELD(f, fmt.win); | 1182 | return ops->vidioc_try_fmt_vid_cap_mplane(file, fh, arg); |
855 | if (likely(ops->vidioc_try_fmt_vid_overlay)) | 1183 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
856 | ret = ops->vidioc_try_fmt_vid_overlay(file, | 1184 | if (unlikely(!ops->vidioc_try_fmt_vid_overlay)) |
857 | fh, f); | ||
858 | break; | 1185 | break; |
859 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1186 | CLEAR_AFTER_FIELD(p, fmt.win); |
860 | CLEAR_AFTER_FIELD(f, fmt.pix); | 1187 | return ops->vidioc_try_fmt_vid_overlay(file, fh, arg); |
861 | if (ops->vidioc_try_fmt_vid_out) | 1188 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
862 | ret = ops->vidioc_try_fmt_vid_out(file, fh, f); | 1189 | if (unlikely(!ops->vidioc_try_fmt_vid_out)) |
863 | if (!ret) | ||
864 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
865 | break; | 1190 | break; |
866 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 1191 | CLEAR_AFTER_FIELD(p, fmt.pix); |
867 | CLEAR_AFTER_FIELD(f, fmt.pix_mp); | 1192 | return ops->vidioc_try_fmt_vid_out(file, fh, arg); |
868 | if (ops->vidioc_try_fmt_vid_out_mplane) | 1193 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
869 | ret = ops->vidioc_try_fmt_vid_out_mplane(file, | 1194 | if (unlikely(!ops->vidioc_try_fmt_vid_out_mplane)) |
870 | fh, f); | ||
871 | if (!ret) | ||
872 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | ||
873 | break; | 1195 | break; |
874 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: | 1196 | CLEAR_AFTER_FIELD(p, fmt.pix_mp); |
875 | CLEAR_AFTER_FIELD(f, fmt.win); | 1197 | return ops->vidioc_try_fmt_vid_out_mplane(file, fh, arg); |
876 | if (likely(ops->vidioc_try_fmt_vid_out_overlay)) | 1198 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
877 | ret = ops->vidioc_try_fmt_vid_out_overlay(file, | 1199 | if (unlikely(!ops->vidioc_try_fmt_vid_out_overlay)) |
878 | fh, f); | ||
879 | break; | 1200 | break; |
880 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1201 | CLEAR_AFTER_FIELD(p, fmt.win); |
881 | CLEAR_AFTER_FIELD(f, fmt.vbi); | 1202 | return ops->vidioc_try_fmt_vid_out_overlay(file, fh, arg); |
882 | if (likely(ops->vidioc_try_fmt_vbi_cap)) | 1203 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
883 | ret = ops->vidioc_try_fmt_vbi_cap(file, fh, f); | 1204 | if (unlikely(!ops->vidioc_try_fmt_vbi_cap)) |
884 | break; | 1205 | break; |
885 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 1206 | CLEAR_AFTER_FIELD(p, fmt.vbi); |
886 | CLEAR_AFTER_FIELD(f, fmt.vbi); | 1207 | return ops->vidioc_try_fmt_vbi_cap(file, fh, arg); |
887 | if (likely(ops->vidioc_try_fmt_vbi_out)) | 1208 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
888 | ret = ops->vidioc_try_fmt_vbi_out(file, fh, f); | 1209 | if (unlikely(!ops->vidioc_try_fmt_vbi_out)) |
889 | break; | 1210 | break; |
890 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | 1211 | CLEAR_AFTER_FIELD(p, fmt.vbi); |
891 | CLEAR_AFTER_FIELD(f, fmt.sliced); | 1212 | return ops->vidioc_try_fmt_vbi_out(file, fh, arg); |
892 | if (likely(ops->vidioc_try_fmt_sliced_vbi_cap)) | 1213 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
893 | ret = ops->vidioc_try_fmt_sliced_vbi_cap(file, | 1214 | if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_cap)) |
894 | fh, f); | ||
895 | break; | 1215 | break; |
896 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | 1216 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
897 | CLEAR_AFTER_FIELD(f, fmt.sliced); | 1217 | return ops->vidioc_try_fmt_sliced_vbi_cap(file, fh, arg); |
898 | if (likely(ops->vidioc_try_fmt_sliced_vbi_out)) | 1218 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
899 | ret = ops->vidioc_try_fmt_sliced_vbi_out(file, | 1219 | if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_out)) |
900 | fh, f); | ||
901 | break; | 1220 | break; |
902 | case V4L2_BUF_TYPE_PRIVATE: | 1221 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
903 | /* CLEAR_AFTER_FIELD(f, fmt.raw_data); <- does nothing */ | 1222 | return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg); |
904 | if (likely(ops->vidioc_try_fmt_type_private)) | 1223 | case V4L2_BUF_TYPE_PRIVATE: |
905 | ret = ops->vidioc_try_fmt_type_private(file, | 1224 | if (unlikely(!ops->vidioc_try_fmt_type_private)) |
906 | fh, f); | ||
907 | break; | 1225 | break; |
908 | } | 1226 | return ops->vidioc_try_fmt_type_private(file, fh, arg); |
909 | break; | ||
910 | } | 1227 | } |
911 | /* FIXME: Those buf reqs could be handled here, | 1228 | return -EINVAL; |
912 | with some changes on videobuf to allow its header to be included at | 1229 | } |
913 | videodev2.h or being merged at videodev2. | ||
914 | */ | ||
915 | case VIDIOC_REQBUFS: | ||
916 | { | ||
917 | struct v4l2_requestbuffers *p = arg; | ||
918 | |||
919 | ret = check_fmt(ops, p->type); | ||
920 | if (ret) | ||
921 | break; | ||
922 | 1230 | ||
923 | if (p->type < V4L2_BUF_TYPE_PRIVATE) | 1231 | static int v4l_streamon(const struct v4l2_ioctl_ops *ops, |
924 | CLEAR_AFTER_FIELD(p, memory); | 1232 | struct file *file, void *fh, void *arg) |
1233 | { | ||
1234 | return ops->vidioc_streamon(file, fh, *(unsigned int *)arg); | ||
1235 | } | ||
925 | 1236 | ||
926 | ret = ops->vidioc_reqbufs(file, fh, p); | 1237 | static int v4l_streamoff(const struct v4l2_ioctl_ops *ops, |
927 | dbgarg(cmd, "count=%d, type=%s, memory=%s\n", | 1238 | struct file *file, void *fh, void *arg) |
928 | p->count, | 1239 | { |
929 | prt_names(p->type, v4l2_type_names), | 1240 | return ops->vidioc_streamoff(file, fh, *(unsigned int *)arg); |
930 | prt_names(p->memory, v4l2_memory_names)); | 1241 | } |
931 | break; | ||
932 | } | ||
933 | case VIDIOC_QUERYBUF: | ||
934 | { | ||
935 | struct v4l2_buffer *p = arg; | ||
936 | 1242 | ||
937 | ret = check_fmt(ops, p->type); | 1243 | static int v4l_g_tuner(const struct v4l2_ioctl_ops *ops, |
938 | if (ret) | 1244 | struct file *file, void *fh, void *arg) |
939 | break; | 1245 | { |
1246 | struct video_device *vfd = video_devdata(file); | ||
1247 | struct v4l2_tuner *p = arg; | ||
940 | 1248 | ||
941 | ret = ops->vidioc_querybuf(file, fh, p); | 1249 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
942 | if (!ret) | 1250 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
943 | dbgbuf(cmd, vfd, p); | 1251 | return ops->vidioc_g_tuner(file, fh, p); |
944 | break; | 1252 | } |
945 | } | ||
946 | case VIDIOC_QBUF: | ||
947 | { | ||
948 | struct v4l2_buffer *p = arg; | ||
949 | 1253 | ||
950 | ret = check_fmt(ops, p->type); | 1254 | static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, |
951 | if (ret) | 1255 | struct file *file, void *fh, void *arg) |
952 | break; | 1256 | { |
1257 | struct video_device *vfd = video_devdata(file); | ||
1258 | struct v4l2_tuner *p = arg; | ||
953 | 1259 | ||
954 | ret = ops->vidioc_qbuf(file, fh, p); | 1260 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
955 | if (!ret) | 1261 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
956 | dbgbuf(cmd, vfd, p); | 1262 | return ops->vidioc_s_tuner(file, fh, p); |
957 | break; | 1263 | } |
958 | } | ||
959 | case VIDIOC_DQBUF: | ||
960 | { | ||
961 | struct v4l2_buffer *p = arg; | ||
962 | 1264 | ||
963 | ret = check_fmt(ops, p->type); | 1265 | static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops, |
964 | if (ret) | 1266 | struct file *file, void *fh, void *arg) |
965 | break; | 1267 | { |
1268 | struct video_device *vfd = video_devdata(file); | ||
1269 | struct v4l2_frequency *p = arg; | ||
966 | 1270 | ||
967 | ret = ops->vidioc_dqbuf(file, fh, p); | 1271 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
968 | if (!ret) | 1272 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
969 | dbgbuf(cmd, vfd, p); | 1273 | return ops->vidioc_g_frequency(file, fh, p); |
970 | break; | 1274 | } |
971 | } | ||
972 | case VIDIOC_OVERLAY: | ||
973 | { | ||
974 | int *i = arg; | ||
975 | 1275 | ||
976 | dbgarg(cmd, "value=%d\n", *i); | 1276 | static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops, |
977 | ret = ops->vidioc_overlay(file, fh, *i); | 1277 | struct file *file, void *fh, void *arg) |
978 | break; | 1278 | { |
979 | } | 1279 | struct video_device *vfd = video_devdata(file); |
980 | case VIDIOC_G_FBUF: | 1280 | struct v4l2_frequency *p = arg; |
981 | { | 1281 | enum v4l2_tuner_type type; |
982 | struct v4l2_framebuffer *p = arg; | ||
983 | |||
984 | ret = ops->vidioc_g_fbuf(file, fh, arg); | ||
985 | if (!ret) { | ||
986 | dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n", | ||
987 | p->capability, p->flags, | ||
988 | (unsigned long)p->base); | ||
989 | v4l_print_pix_fmt(vfd, &p->fmt); | ||
990 | } | ||
991 | break; | ||
992 | } | ||
993 | case VIDIOC_S_FBUF: | ||
994 | { | ||
995 | struct v4l2_framebuffer *p = arg; | ||
996 | |||
997 | dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n", | ||
998 | p->capability, p->flags, (unsigned long)p->base); | ||
999 | v4l_print_pix_fmt(vfd, &p->fmt); | ||
1000 | ret = ops->vidioc_s_fbuf(file, fh, arg); | ||
1001 | break; | ||
1002 | } | ||
1003 | case VIDIOC_STREAMON: | ||
1004 | { | ||
1005 | enum v4l2_buf_type i = *(int *)arg; | ||
1006 | 1282 | ||
1007 | dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); | 1283 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
1008 | ret = ops->vidioc_streamon(file, fh, i); | 1284 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
1009 | break; | 1285 | if (p->type != type) |
1010 | } | 1286 | return -EINVAL; |
1011 | case VIDIOC_STREAMOFF: | 1287 | return ops->vidioc_s_frequency(file, fh, p); |
1012 | { | 1288 | } |
1013 | enum v4l2_buf_type i = *(int *)arg; | ||
1014 | 1289 | ||
1015 | dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); | 1290 | static int v4l_enumstd(const struct v4l2_ioctl_ops *ops, |
1016 | ret = ops->vidioc_streamoff(file, fh, i); | 1291 | struct file *file, void *fh, void *arg) |
1017 | break; | 1292 | { |
1018 | } | 1293 | struct video_device *vfd = video_devdata(file); |
1019 | /* ---------- tv norms ---------- */ | 1294 | struct v4l2_standard *p = arg; |
1020 | case VIDIOC_ENUMSTD: | 1295 | v4l2_std_id id = vfd->tvnorms, curr_id = 0; |
1021 | { | 1296 | unsigned int index = p->index, i, j = 0; |
1022 | struct v4l2_standard *p = arg; | 1297 | const char *descr = ""; |
1023 | v4l2_std_id id = vfd->tvnorms, curr_id = 0; | 1298 | |
1024 | unsigned int index = p->index, i, j = 0; | 1299 | /* Return norm array in a canonical way */ |
1025 | const char *descr = ""; | 1300 | for (i = 0; i <= index && id; i++) { |
1026 | 1301 | /* last std value in the standards array is 0, so this | |
1027 | if (id == 0) | 1302 | while always ends there since (id & 0) == 0. */ |
1028 | break; | 1303 | while ((id & standards[j].std) != standards[j].std) |
1029 | ret = -EINVAL; | ||
1030 | |||
1031 | /* Return norm array in a canonical way */ | ||
1032 | for (i = 0; i <= index && id; i++) { | ||
1033 | /* last std value in the standards array is 0, so this | ||
1034 | while always ends there since (id & 0) == 0. */ | ||
1035 | while ((id & standards[j].std) != standards[j].std) | ||
1036 | j++; | ||
1037 | curr_id = standards[j].std; | ||
1038 | descr = standards[j].descr; | ||
1039 | j++; | 1304 | j++; |
1040 | if (curr_id == 0) | 1305 | curr_id = standards[j].std; |
1041 | break; | 1306 | descr = standards[j].descr; |
1042 | if (curr_id != V4L2_STD_PAL && | 1307 | j++; |
1043 | curr_id != V4L2_STD_SECAM && | 1308 | if (curr_id == 0) |
1044 | curr_id != V4L2_STD_NTSC) | ||
1045 | id &= ~curr_id; | ||
1046 | } | ||
1047 | if (i <= index) | ||
1048 | break; | 1309 | break; |
1049 | 1310 | if (curr_id != V4L2_STD_PAL && | |
1050 | v4l2_video_std_construct(p, curr_id, descr); | 1311 | curr_id != V4L2_STD_SECAM && |
1051 | 1312 | curr_id != V4L2_STD_NTSC) | |
1052 | dbgarg(cmd, "index=%d, id=0x%Lx, name=%s, fps=%d/%d, " | 1313 | id &= ~curr_id; |
1053 | "framelines=%d\n", p->index, | ||
1054 | (unsigned long long)p->id, p->name, | ||
1055 | p->frameperiod.numerator, | ||
1056 | p->frameperiod.denominator, | ||
1057 | p->framelines); | ||
1058 | |||
1059 | ret = 0; | ||
1060 | break; | ||
1061 | } | ||
1062 | case VIDIOC_G_STD: | ||
1063 | { | ||
1064 | v4l2_std_id *id = arg; | ||
1065 | |||
1066 | /* Calls the specific handler */ | ||
1067 | if (ops->vidioc_g_std) | ||
1068 | ret = ops->vidioc_g_std(file, fh, id); | ||
1069 | else if (vfd->current_norm) { | ||
1070 | ret = 0; | ||
1071 | *id = vfd->current_norm; | ||
1072 | } | ||
1073 | |||
1074 | if (likely(!ret)) | ||
1075 | dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id); | ||
1076 | break; | ||
1077 | } | 1314 | } |
1078 | case VIDIOC_S_STD: | 1315 | if (i <= index) |
1079 | { | 1316 | return -EINVAL; |
1080 | v4l2_std_id *id = arg, norm; | ||
1081 | |||
1082 | dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id); | ||
1083 | |||
1084 | ret = -EINVAL; | ||
1085 | norm = (*id) & vfd->tvnorms; | ||
1086 | if (vfd->tvnorms && !norm) /* Check if std is supported */ | ||
1087 | break; | ||
1088 | |||
1089 | /* Calls the specific handler */ | ||
1090 | ret = ops->vidioc_s_std(file, fh, &norm); | ||
1091 | |||
1092 | /* Updates standard information */ | ||
1093 | if (ret >= 0) | ||
1094 | vfd->current_norm = norm; | ||
1095 | break; | ||
1096 | } | ||
1097 | case VIDIOC_QUERYSTD: | ||
1098 | { | ||
1099 | v4l2_std_id *p = arg; | ||
1100 | |||
1101 | /* | ||
1102 | * If nothing detected, it should return all supported | ||
1103 | * Drivers just need to mask the std argument, in order | ||
1104 | * to remove the standards that don't apply from the mask. | ||
1105 | * This means that tuners, audio and video decoders can join | ||
1106 | * their efforts to improve the standards detection | ||
1107 | */ | ||
1108 | *p = vfd->tvnorms; | ||
1109 | ret = ops->vidioc_querystd(file, fh, arg); | ||
1110 | if (!ret) | ||
1111 | dbgarg(cmd, "detected std=%08Lx\n", | ||
1112 | (unsigned long long)*p); | ||
1113 | break; | ||
1114 | } | ||
1115 | /* ------ input switching ---------- */ | ||
1116 | /* FIXME: Inputs can be handled inside videodev2 */ | ||
1117 | case VIDIOC_ENUMINPUT: | ||
1118 | { | ||
1119 | struct v4l2_input *p = arg; | ||
1120 | 1317 | ||
1121 | /* | 1318 | v4l2_video_std_construct(p, curr_id, descr); |
1122 | * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & | 1319 | return 0; |
1123 | * CAP_STD here based on ioctl handler provided by the | 1320 | } |
1124 | * driver. If the driver doesn't support these | ||
1125 | * for a specific input, it must override these flags. | ||
1126 | */ | ||
1127 | if (ops->vidioc_s_std) | ||
1128 | p->capabilities |= V4L2_IN_CAP_STD; | ||
1129 | if (ops->vidioc_s_dv_preset) | ||
1130 | p->capabilities |= V4L2_IN_CAP_PRESETS; | ||
1131 | if (ops->vidioc_s_dv_timings) | ||
1132 | p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS; | ||
1133 | |||
1134 | ret = ops->vidioc_enum_input(file, fh, p); | ||
1135 | if (!ret) | ||
1136 | dbgarg(cmd, "index=%d, name=%s, type=%d, " | ||
1137 | "audioset=%d, " | ||
1138 | "tuner=%d, std=%08Lx, status=%d\n", | ||
1139 | p->index, p->name, p->type, p->audioset, | ||
1140 | p->tuner, | ||
1141 | (unsigned long long)p->std, | ||
1142 | p->status); | ||
1143 | break; | ||
1144 | } | ||
1145 | case VIDIOC_G_INPUT: | ||
1146 | { | ||
1147 | unsigned int *i = arg; | ||
1148 | 1321 | ||
1149 | ret = ops->vidioc_g_input(file, fh, i); | 1322 | static int v4l_g_std(const struct v4l2_ioctl_ops *ops, |
1150 | if (!ret) | 1323 | struct file *file, void *fh, void *arg) |
1151 | dbgarg(cmd, "value=%d\n", *i); | 1324 | { |
1152 | break; | 1325 | struct video_device *vfd = video_devdata(file); |
1153 | } | 1326 | v4l2_std_id *id = arg; |
1154 | case VIDIOC_S_INPUT: | ||
1155 | { | ||
1156 | unsigned int *i = arg; | ||
1157 | 1327 | ||
1158 | dbgarg(cmd, "value=%d\n", *i); | 1328 | /* Calls the specific handler */ |
1159 | ret = ops->vidioc_s_input(file, fh, *i); | 1329 | if (ops->vidioc_g_std) |
1160 | break; | 1330 | return ops->vidioc_g_std(file, fh, arg); |
1331 | if (vfd->current_norm) { | ||
1332 | *id = vfd->current_norm; | ||
1333 | return 0; | ||
1161 | } | 1334 | } |
1335 | return -ENOTTY; | ||
1336 | } | ||
1162 | 1337 | ||
1163 | /* ------ output switching ---------- */ | 1338 | static int v4l_s_std(const struct v4l2_ioctl_ops *ops, |
1164 | case VIDIOC_ENUMOUTPUT: | 1339 | struct file *file, void *fh, void *arg) |
1165 | { | 1340 | { |
1166 | struct v4l2_output *p = arg; | 1341 | struct video_device *vfd = video_devdata(file); |
1167 | 1342 | v4l2_std_id *id = arg, norm; | |
1168 | /* | 1343 | int ret; |
1169 | * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & | ||
1170 | * CAP_STD here based on ioctl handler provided by the | ||
1171 | * driver. If the driver doesn't support these | ||
1172 | * for a specific output, it must override these flags. | ||
1173 | */ | ||
1174 | if (ops->vidioc_s_std) | ||
1175 | p->capabilities |= V4L2_OUT_CAP_STD; | ||
1176 | if (ops->vidioc_s_dv_preset) | ||
1177 | p->capabilities |= V4L2_OUT_CAP_PRESETS; | ||
1178 | if (ops->vidioc_s_dv_timings) | ||
1179 | p->capabilities |= V4L2_OUT_CAP_CUSTOM_TIMINGS; | ||
1180 | |||
1181 | ret = ops->vidioc_enum_output(file, fh, p); | ||
1182 | if (!ret) | ||
1183 | dbgarg(cmd, "index=%d, name=%s, type=%d, " | ||
1184 | "audioset=0x%x, " | ||
1185 | "modulator=%d, std=0x%08Lx\n", | ||
1186 | p->index, p->name, p->type, p->audioset, | ||
1187 | p->modulator, (unsigned long long)p->std); | ||
1188 | break; | ||
1189 | } | ||
1190 | case VIDIOC_G_OUTPUT: | ||
1191 | { | ||
1192 | unsigned int *i = arg; | ||
1193 | 1344 | ||
1194 | ret = ops->vidioc_g_output(file, fh, i); | 1345 | norm = (*id) & vfd->tvnorms; |
1195 | if (!ret) | 1346 | if (vfd->tvnorms && !norm) /* Check if std is supported */ |
1196 | dbgarg(cmd, "value=%d\n", *i); | 1347 | return -EINVAL; |
1197 | break; | ||
1198 | } | ||
1199 | case VIDIOC_S_OUTPUT: | ||
1200 | { | ||
1201 | unsigned int *i = arg; | ||
1202 | 1348 | ||
1203 | dbgarg(cmd, "value=%d\n", *i); | 1349 | /* Calls the specific handler */ |
1204 | ret = ops->vidioc_s_output(file, fh, *i); | 1350 | ret = ops->vidioc_s_std(file, fh, &norm); |
1205 | break; | ||
1206 | } | ||
1207 | 1351 | ||
1208 | /* --- controls ---------------------------------------------- */ | 1352 | /* Updates standard information */ |
1209 | case VIDIOC_QUERYCTRL: | 1353 | if (ret >= 0) |
1210 | { | 1354 | vfd->current_norm = norm; |
1211 | struct v4l2_queryctrl *p = arg; | 1355 | return ret; |
1212 | 1356 | } | |
1213 | if (vfh && vfh->ctrl_handler) | ||
1214 | ret = v4l2_queryctrl(vfh->ctrl_handler, p); | ||
1215 | else if (vfd->ctrl_handler) | ||
1216 | ret = v4l2_queryctrl(vfd->ctrl_handler, p); | ||
1217 | else if (ops->vidioc_queryctrl) | ||
1218 | ret = ops->vidioc_queryctrl(file, fh, p); | ||
1219 | else | ||
1220 | break; | ||
1221 | if (!ret) | ||
1222 | dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, " | ||
1223 | "step=%d, default=%d, flags=0x%08x\n", | ||
1224 | p->id, p->type, p->name, | ||
1225 | p->minimum, p->maximum, | ||
1226 | p->step, p->default_value, p->flags); | ||
1227 | else | ||
1228 | dbgarg(cmd, "id=0x%x\n", p->id); | ||
1229 | break; | ||
1230 | } | ||
1231 | case VIDIOC_G_CTRL: | ||
1232 | { | ||
1233 | struct v4l2_control *p = arg; | ||
1234 | |||
1235 | if (vfh && vfh->ctrl_handler) | ||
1236 | ret = v4l2_g_ctrl(vfh->ctrl_handler, p); | ||
1237 | else if (vfd->ctrl_handler) | ||
1238 | ret = v4l2_g_ctrl(vfd->ctrl_handler, p); | ||
1239 | else if (ops->vidioc_g_ctrl) | ||
1240 | ret = ops->vidioc_g_ctrl(file, fh, p); | ||
1241 | else if (ops->vidioc_g_ext_ctrls) { | ||
1242 | struct v4l2_ext_controls ctrls; | ||
1243 | struct v4l2_ext_control ctrl; | ||
1244 | |||
1245 | ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); | ||
1246 | ctrls.count = 1; | ||
1247 | ctrls.controls = &ctrl; | ||
1248 | ctrl.id = p->id; | ||
1249 | ctrl.value = p->value; | ||
1250 | if (check_ext_ctrls(&ctrls, 1)) { | ||
1251 | ret = ops->vidioc_g_ext_ctrls(file, fh, &ctrls); | ||
1252 | if (ret == 0) | ||
1253 | p->value = ctrl.value; | ||
1254 | } | ||
1255 | } else | ||
1256 | break; | ||
1257 | if (!ret) | ||
1258 | dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value); | ||
1259 | else | ||
1260 | dbgarg(cmd, "id=0x%x\n", p->id); | ||
1261 | break; | ||
1262 | } | ||
1263 | case VIDIOC_S_CTRL: | ||
1264 | { | ||
1265 | struct v4l2_control *p = arg; | ||
1266 | struct v4l2_ext_controls ctrls; | ||
1267 | struct v4l2_ext_control ctrl; | ||
1268 | |||
1269 | if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler && | ||
1270 | !ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls) | ||
1271 | break; | ||
1272 | 1357 | ||
1273 | dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value); | 1358 | static int v4l_querystd(const struct v4l2_ioctl_ops *ops, |
1359 | struct file *file, void *fh, void *arg) | ||
1360 | { | ||
1361 | struct video_device *vfd = video_devdata(file); | ||
1362 | v4l2_std_id *p = arg; | ||
1363 | |||
1364 | /* | ||
1365 | * If nothing detected, it should return all supported | ||
1366 | * standard. | ||
1367 | * Drivers just need to mask the std argument, in order | ||
1368 | * to remove the standards that don't apply from the mask. | ||
1369 | * This means that tuners, audio and video decoders can join | ||
1370 | * their efforts to improve the standards detection. | ||
1371 | */ | ||
1372 | *p = vfd->tvnorms; | ||
1373 | return ops->vidioc_querystd(file, fh, arg); | ||
1374 | } | ||
1274 | 1375 | ||
1275 | if (vfh && vfh->ctrl_handler) { | 1376 | static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, |
1276 | ret = v4l2_s_ctrl(vfh, vfh->ctrl_handler, p); | 1377 | struct file *file, void *fh, void *arg) |
1277 | break; | 1378 | { |
1278 | } | 1379 | struct video_device *vfd = video_devdata(file); |
1279 | if (vfd->ctrl_handler) { | 1380 | struct v4l2_hw_freq_seek *p = arg; |
1280 | ret = v4l2_s_ctrl(NULL, vfd->ctrl_handler, p); | 1381 | enum v4l2_tuner_type type; |
1281 | break; | ||
1282 | } | ||
1283 | if (ops->vidioc_s_ctrl) { | ||
1284 | ret = ops->vidioc_s_ctrl(file, fh, p); | ||
1285 | break; | ||
1286 | } | ||
1287 | if (!ops->vidioc_s_ext_ctrls) | ||
1288 | break; | ||
1289 | 1382 | ||
1290 | ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); | 1383 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
1291 | ctrls.count = 1; | 1384 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
1292 | ctrls.controls = &ctrl; | 1385 | if (p->type != type) |
1293 | ctrl.id = p->id; | 1386 | return -EINVAL; |
1294 | ctrl.value = p->value; | 1387 | return ops->vidioc_s_hw_freq_seek(file, fh, p); |
1295 | if (check_ext_ctrls(&ctrls, 1)) | 1388 | } |
1296 | ret = ops->vidioc_s_ext_ctrls(file, fh, &ctrls); | ||
1297 | else | ||
1298 | ret = -EINVAL; | ||
1299 | break; | ||
1300 | } | ||
1301 | case VIDIOC_G_EXT_CTRLS: | ||
1302 | { | ||
1303 | struct v4l2_ext_controls *p = arg; | ||
1304 | |||
1305 | p->error_idx = p->count; | ||
1306 | if (vfh && vfh->ctrl_handler) | ||
1307 | ret = v4l2_g_ext_ctrls(vfh->ctrl_handler, p); | ||
1308 | else if (vfd->ctrl_handler) | ||
1309 | ret = v4l2_g_ext_ctrls(vfd->ctrl_handler, p); | ||
1310 | else if (ops->vidioc_g_ext_ctrls) | ||
1311 | ret = check_ext_ctrls(p, 0) ? | ||
1312 | ops->vidioc_g_ext_ctrls(file, fh, p) : | ||
1313 | -EINVAL; | ||
1314 | else | ||
1315 | break; | ||
1316 | v4l_print_ext_ctrls(cmd, vfd, p, !ret); | ||
1317 | break; | ||
1318 | } | ||
1319 | case VIDIOC_S_EXT_CTRLS: | ||
1320 | { | ||
1321 | struct v4l2_ext_controls *p = arg; | ||
1322 | 1389 | ||
1323 | p->error_idx = p->count; | 1390 | static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops, |
1324 | if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler && | 1391 | struct file *file, void *fh, void *arg) |
1325 | !ops->vidioc_s_ext_ctrls) | 1392 | { |
1326 | break; | 1393 | struct v4l2_requestbuffers *p = arg; |
1327 | v4l_print_ext_ctrls(cmd, vfd, p, 1); | 1394 | int ret = check_fmt(ops, p->type); |
1328 | if (vfh && vfh->ctrl_handler) | ||
1329 | ret = v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, p); | ||
1330 | else if (vfd->ctrl_handler) | ||
1331 | ret = v4l2_s_ext_ctrls(NULL, vfd->ctrl_handler, p); | ||
1332 | else if (check_ext_ctrls(p, 0)) | ||
1333 | ret = ops->vidioc_s_ext_ctrls(file, fh, p); | ||
1334 | else | ||
1335 | ret = -EINVAL; | ||
1336 | break; | ||
1337 | } | ||
1338 | case VIDIOC_TRY_EXT_CTRLS: | ||
1339 | { | ||
1340 | struct v4l2_ext_controls *p = arg; | ||
1341 | 1395 | ||
1342 | p->error_idx = p->count; | 1396 | if (ret) |
1343 | if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler && | 1397 | return ret; |
1344 | !ops->vidioc_try_ext_ctrls) | ||
1345 | break; | ||
1346 | v4l_print_ext_ctrls(cmd, vfd, p, 1); | ||
1347 | if (vfh && vfh->ctrl_handler) | ||
1348 | ret = v4l2_try_ext_ctrls(vfh->ctrl_handler, p); | ||
1349 | else if (vfd->ctrl_handler) | ||
1350 | ret = v4l2_try_ext_ctrls(vfd->ctrl_handler, p); | ||
1351 | else if (check_ext_ctrls(p, 0)) | ||
1352 | ret = ops->vidioc_try_ext_ctrls(file, fh, p); | ||
1353 | else | ||
1354 | ret = -EINVAL; | ||
1355 | break; | ||
1356 | } | ||
1357 | case VIDIOC_QUERYMENU: | ||
1358 | { | ||
1359 | struct v4l2_querymenu *p = arg; | ||
1360 | |||
1361 | if (vfh && vfh->ctrl_handler) | ||
1362 | ret = v4l2_querymenu(vfh->ctrl_handler, p); | ||
1363 | else if (vfd->ctrl_handler) | ||
1364 | ret = v4l2_querymenu(vfd->ctrl_handler, p); | ||
1365 | else if (ops->vidioc_querymenu) | ||
1366 | ret = ops->vidioc_querymenu(file, fh, p); | ||
1367 | else | ||
1368 | break; | ||
1369 | if (!ret) | ||
1370 | dbgarg(cmd, "id=0x%x, index=%d, name=%s\n", | ||
1371 | p->id, p->index, p->name); | ||
1372 | else | ||
1373 | dbgarg(cmd, "id=0x%x, index=%d\n", | ||
1374 | p->id, p->index); | ||
1375 | break; | ||
1376 | } | ||
1377 | /* --- audio ---------------------------------------------- */ | ||
1378 | case VIDIOC_ENUMAUDIO: | ||
1379 | { | ||
1380 | struct v4l2_audio *p = arg; | ||
1381 | |||
1382 | ret = ops->vidioc_enumaudio(file, fh, p); | ||
1383 | if (!ret) | ||
1384 | dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " | ||
1385 | "mode=0x%x\n", p->index, p->name, | ||
1386 | p->capability, p->mode); | ||
1387 | else | ||
1388 | dbgarg(cmd, "index=%d\n", p->index); | ||
1389 | break; | ||
1390 | } | ||
1391 | case VIDIOC_G_AUDIO: | ||
1392 | { | ||
1393 | struct v4l2_audio *p = arg; | ||
1394 | |||
1395 | ret = ops->vidioc_g_audio(file, fh, p); | ||
1396 | if (!ret) | ||
1397 | dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " | ||
1398 | "mode=0x%x\n", p->index, | ||
1399 | p->name, p->capability, p->mode); | ||
1400 | else | ||
1401 | dbgarg(cmd, "index=%d\n", p->index); | ||
1402 | break; | ||
1403 | } | ||
1404 | case VIDIOC_S_AUDIO: | ||
1405 | { | ||
1406 | struct v4l2_audio *p = arg; | ||
1407 | |||
1408 | dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " | ||
1409 | "mode=0x%x\n", p->index, p->name, | ||
1410 | p->capability, p->mode); | ||
1411 | ret = ops->vidioc_s_audio(file, fh, p); | ||
1412 | break; | ||
1413 | } | ||
1414 | case VIDIOC_ENUMAUDOUT: | ||
1415 | { | ||
1416 | struct v4l2_audioout *p = arg; | ||
1417 | |||
1418 | dbgarg(cmd, "Enum for index=%d\n", p->index); | ||
1419 | ret = ops->vidioc_enumaudout(file, fh, p); | ||
1420 | if (!ret) | ||
1421 | dbgarg2("index=%d, name=%s, capability=%d, " | ||
1422 | "mode=%d\n", p->index, p->name, | ||
1423 | p->capability, p->mode); | ||
1424 | break; | ||
1425 | } | ||
1426 | case VIDIOC_G_AUDOUT: | ||
1427 | { | ||
1428 | struct v4l2_audioout *p = arg; | ||
1429 | |||
1430 | ret = ops->vidioc_g_audout(file, fh, p); | ||
1431 | if (!ret) | ||
1432 | dbgarg2("index=%d, name=%s, capability=%d, " | ||
1433 | "mode=%d\n", p->index, p->name, | ||
1434 | p->capability, p->mode); | ||
1435 | break; | ||
1436 | } | ||
1437 | case VIDIOC_S_AUDOUT: | ||
1438 | { | ||
1439 | struct v4l2_audioout *p = arg; | ||
1440 | 1398 | ||
1441 | dbgarg(cmd, "index=%d, name=%s, capability=%d, " | 1399 | if (p->type < V4L2_BUF_TYPE_PRIVATE) |
1442 | "mode=%d\n", p->index, p->name, | 1400 | CLEAR_AFTER_FIELD(p, memory); |
1443 | p->capability, p->mode); | ||
1444 | 1401 | ||
1445 | ret = ops->vidioc_s_audout(file, fh, p); | 1402 | return ops->vidioc_reqbufs(file, fh, p); |
1446 | break; | 1403 | } |
1447 | } | ||
1448 | case VIDIOC_G_MODULATOR: | ||
1449 | { | ||
1450 | struct v4l2_modulator *p = arg; | ||
1451 | |||
1452 | ret = ops->vidioc_g_modulator(file, fh, p); | ||
1453 | if (!ret) | ||
1454 | dbgarg(cmd, "index=%d, name=%s, " | ||
1455 | "capability=%d, rangelow=%d," | ||
1456 | " rangehigh=%d, txsubchans=%d\n", | ||
1457 | p->index, p->name, p->capability, | ||
1458 | p->rangelow, p->rangehigh, | ||
1459 | p->txsubchans); | ||
1460 | break; | ||
1461 | } | ||
1462 | case VIDIOC_S_MODULATOR: | ||
1463 | { | ||
1464 | struct v4l2_modulator *p = arg; | ||
1465 | |||
1466 | dbgarg(cmd, "index=%d, name=%s, capability=%d, " | ||
1467 | "rangelow=%d, rangehigh=%d, txsubchans=%d\n", | ||
1468 | p->index, p->name, p->capability, p->rangelow, | ||
1469 | p->rangehigh, p->txsubchans); | ||
1470 | ret = ops->vidioc_s_modulator(file, fh, p); | ||
1471 | break; | ||
1472 | } | ||
1473 | case VIDIOC_G_CROP: | ||
1474 | { | ||
1475 | struct v4l2_crop *p = arg; | ||
1476 | 1404 | ||
1477 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1405 | static int v4l_querybuf(const struct v4l2_ioctl_ops *ops, |
1406 | struct file *file, void *fh, void *arg) | ||
1407 | { | ||
1408 | struct v4l2_buffer *p = arg; | ||
1409 | int ret = check_fmt(ops, p->type); | ||
1478 | 1410 | ||
1479 | if (ops->vidioc_g_crop) { | 1411 | return ret ? ret : ops->vidioc_querybuf(file, fh, p); |
1480 | ret = ops->vidioc_g_crop(file, fh, p); | 1412 | } |
1481 | } else { | ||
1482 | /* simulate capture crop using selection api */ | ||
1483 | struct v4l2_selection s = { | ||
1484 | .type = p->type, | ||
1485 | }; | ||
1486 | |||
1487 | /* crop means compose for output devices */ | ||
1488 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1489 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1490 | else | ||
1491 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1492 | |||
1493 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1494 | |||
1495 | /* copying results to old structure on success */ | ||
1496 | if (!ret) | ||
1497 | p->c = s.r; | ||
1498 | } | ||
1499 | 1413 | ||
1500 | if (!ret) | 1414 | static int v4l_qbuf(const struct v4l2_ioctl_ops *ops, |
1501 | dbgrect(vfd, "", &p->c); | 1415 | struct file *file, void *fh, void *arg) |
1502 | break; | 1416 | { |
1503 | } | 1417 | struct v4l2_buffer *p = arg; |
1504 | case VIDIOC_S_CROP: | 1418 | int ret = check_fmt(ops, p->type); |
1505 | { | ||
1506 | struct v4l2_crop *p = arg; | ||
1507 | 1419 | ||
1508 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1420 | return ret ? ret : ops->vidioc_qbuf(file, fh, p); |
1509 | dbgrect(vfd, "", &p->c); | 1421 | } |
1510 | 1422 | ||
1511 | if (ops->vidioc_s_crop) { | 1423 | static int v4l_dqbuf(const struct v4l2_ioctl_ops *ops, |
1512 | ret = ops->vidioc_s_crop(file, fh, p); | 1424 | struct file *file, void *fh, void *arg) |
1513 | } else { | 1425 | { |
1514 | /* simulate capture crop using selection api */ | 1426 | struct v4l2_buffer *p = arg; |
1515 | struct v4l2_selection s = { | 1427 | int ret = check_fmt(ops, p->type); |
1516 | .type = p->type, | ||
1517 | .r = p->c, | ||
1518 | }; | ||
1519 | |||
1520 | /* crop means compose for output devices */ | ||
1521 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1522 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1523 | else | ||
1524 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1525 | |||
1526 | ret = ops->vidioc_s_selection(file, fh, &s); | ||
1527 | } | ||
1528 | break; | ||
1529 | } | ||
1530 | case VIDIOC_G_SELECTION: | ||
1531 | { | ||
1532 | struct v4l2_selection *p = arg; | ||
1533 | 1428 | ||
1534 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1429 | return ret ? ret : ops->vidioc_dqbuf(file, fh, p); |
1430 | } | ||
1535 | 1431 | ||
1536 | ret = ops->vidioc_g_selection(file, fh, p); | 1432 | static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops, |
1537 | if (!ret) | 1433 | struct file *file, void *fh, void *arg) |
1538 | dbgrect(vfd, "", &p->r); | 1434 | { |
1539 | break; | 1435 | struct v4l2_create_buffers *create = arg; |
1540 | } | 1436 | int ret = check_fmt(ops, create->format.type); |
1541 | case VIDIOC_S_SELECTION: | ||
1542 | { | ||
1543 | struct v4l2_selection *p = arg; | ||
1544 | 1437 | ||
1438 | return ret ? ret : ops->vidioc_create_bufs(file, fh, create); | ||
1439 | } | ||
1545 | 1440 | ||
1546 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1441 | static int v4l_prepare_buf(const struct v4l2_ioctl_ops *ops, |
1547 | dbgrect(vfd, "", &p->r); | 1442 | struct file *file, void *fh, void *arg) |
1443 | { | ||
1444 | struct v4l2_buffer *b = arg; | ||
1445 | int ret = check_fmt(ops, b->type); | ||
1548 | 1446 | ||
1549 | ret = ops->vidioc_s_selection(file, fh, p); | 1447 | return ret ? ret : ops->vidioc_prepare_buf(file, fh, b); |
1550 | break; | 1448 | } |
1551 | } | ||
1552 | case VIDIOC_CROPCAP: | ||
1553 | { | ||
1554 | struct v4l2_cropcap *p = arg; | ||
1555 | |||
1556 | /*FIXME: Should also show v4l2_fract pixelaspect */ | ||
1557 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1558 | if (ops->vidioc_cropcap) { | ||
1559 | ret = ops->vidioc_cropcap(file, fh, p); | ||
1560 | } else { | ||
1561 | struct v4l2_selection s = { .type = p->type }; | ||
1562 | 1449 | ||
1563 | /* obtaining bounds */ | 1450 | static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, |
1564 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | 1451 | struct file *file, void *fh, void *arg) |
1565 | s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; | 1452 | { |
1566 | else | 1453 | struct video_device *vfd = video_devdata(file); |
1567 | s.target = V4L2_SEL_TGT_CROP_BOUNDS; | 1454 | struct v4l2_streamparm *p = arg; |
1455 | v4l2_std_id std; | ||
1456 | int ret = check_fmt(ops, p->type); | ||
1568 | 1457 | ||
1569 | ret = ops->vidioc_g_selection(file, fh, &s); | 1458 | if (ret) |
1570 | if (ret) | 1459 | return ret; |
1571 | break; | 1460 | if (ops->vidioc_g_parm) |
1572 | p->bounds = s.r; | 1461 | return ops->vidioc_g_parm(file, fh, p); |
1462 | std = vfd->current_norm; | ||
1463 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && | ||
1464 | p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) | ||
1465 | return -EINVAL; | ||
1466 | p->parm.capture.readbuffers = 2; | ||
1467 | if (ops->vidioc_g_std) | ||
1468 | ret = ops->vidioc_g_std(file, fh, &std); | ||
1469 | if (ret == 0) | ||
1470 | v4l2_video_std_frame_period(std, | ||
1471 | &p->parm.capture.timeperframe); | ||
1472 | return ret; | ||
1473 | } | ||
1573 | 1474 | ||
1574 | /* obtaining defrect */ | 1475 | static int v4l_s_parm(const struct v4l2_ioctl_ops *ops, |
1575 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | 1476 | struct file *file, void *fh, void *arg) |
1576 | s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; | 1477 | { |
1577 | else | 1478 | struct v4l2_streamparm *p = arg; |
1578 | s.target = V4L2_SEL_TGT_CROP_DEFAULT; | 1479 | int ret = check_fmt(ops, p->type); |
1579 | 1480 | ||
1580 | ret = ops->vidioc_g_selection(file, fh, &s); | 1481 | return ret ? ret : ops->vidioc_s_parm(file, fh, p); |
1581 | if (ret) | 1482 | } |
1582 | break; | ||
1583 | p->defrect = s.r; | ||
1584 | 1483 | ||
1585 | /* setting trivial pixelaspect */ | 1484 | static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, |
1586 | p->pixelaspect.numerator = 1; | 1485 | struct file *file, void *fh, void *arg) |
1587 | p->pixelaspect.denominator = 1; | 1486 | { |
1588 | } | 1487 | struct video_device *vfd = video_devdata(file); |
1488 | struct v4l2_queryctrl *p = arg; | ||
1489 | struct v4l2_fh *vfh = fh; | ||
1490 | |||
1491 | if (vfh && vfh->ctrl_handler) | ||
1492 | return v4l2_queryctrl(vfh->ctrl_handler, p); | ||
1493 | if (vfd->ctrl_handler) | ||
1494 | return v4l2_queryctrl(vfd->ctrl_handler, p); | ||
1495 | if (ops->vidioc_queryctrl) | ||
1496 | return ops->vidioc_queryctrl(file, fh, p); | ||
1497 | return -ENOTTY; | ||
1498 | } | ||
1589 | 1499 | ||
1590 | if (!ret) { | 1500 | static int v4l_querymenu(const struct v4l2_ioctl_ops *ops, |
1591 | dbgrect(vfd, "bounds ", &p->bounds); | 1501 | struct file *file, void *fh, void *arg) |
1592 | dbgrect(vfd, "defrect ", &p->defrect); | 1502 | { |
1593 | } | 1503 | struct video_device *vfd = video_devdata(file); |
1594 | break; | 1504 | struct v4l2_querymenu *p = arg; |
1595 | } | 1505 | struct v4l2_fh *vfh = fh; |
1596 | case VIDIOC_G_JPEGCOMP: | 1506 | |
1597 | { | 1507 | if (vfh && vfh->ctrl_handler) |
1598 | struct v4l2_jpegcompression *p = arg; | 1508 | return v4l2_querymenu(vfh->ctrl_handler, p); |
1599 | 1509 | if (vfd->ctrl_handler) | |
1600 | ret = ops->vidioc_g_jpegcomp(file, fh, p); | 1510 | return v4l2_querymenu(vfd->ctrl_handler, p); |
1601 | if (!ret) | 1511 | if (ops->vidioc_querymenu) |
1602 | dbgarg(cmd, "quality=%d, APPn=%d, " | 1512 | return ops->vidioc_querymenu(file, fh, p); |
1603 | "APP_len=%d, COM_len=%d, " | 1513 | return -ENOTTY; |
1604 | "jpeg_markers=%d\n", | 1514 | } |
1605 | p->quality, p->APPn, p->APP_len, | ||
1606 | p->COM_len, p->jpeg_markers); | ||
1607 | break; | ||
1608 | } | ||
1609 | case VIDIOC_S_JPEGCOMP: | ||
1610 | { | ||
1611 | struct v4l2_jpegcompression *p = arg; | ||
1612 | |||
1613 | dbgarg(cmd, "quality=%d, APPn=%d, APP_len=%d, " | ||
1614 | "COM_len=%d, jpeg_markers=%d\n", | ||
1615 | p->quality, p->APPn, p->APP_len, | ||
1616 | p->COM_len, p->jpeg_markers); | ||
1617 | ret = ops->vidioc_s_jpegcomp(file, fh, p); | ||
1618 | break; | ||
1619 | } | ||
1620 | case VIDIOC_G_ENC_INDEX: | ||
1621 | { | ||
1622 | struct v4l2_enc_idx *p = arg; | ||
1623 | |||
1624 | ret = ops->vidioc_g_enc_index(file, fh, p); | ||
1625 | if (!ret) | ||
1626 | dbgarg(cmd, "entries=%d, entries_cap=%d\n", | ||
1627 | p->entries, p->entries_cap); | ||
1628 | break; | ||
1629 | } | ||
1630 | case VIDIOC_ENCODER_CMD: | ||
1631 | { | ||
1632 | struct v4l2_encoder_cmd *p = arg; | ||
1633 | 1515 | ||
1634 | ret = ops->vidioc_encoder_cmd(file, fh, p); | 1516 | static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, |
1635 | if (!ret) | 1517 | struct file *file, void *fh, void *arg) |
1636 | dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); | 1518 | { |
1637 | break; | 1519 | struct video_device *vfd = video_devdata(file); |
1520 | struct v4l2_control *p = arg; | ||
1521 | struct v4l2_fh *vfh = fh; | ||
1522 | struct v4l2_ext_controls ctrls; | ||
1523 | struct v4l2_ext_control ctrl; | ||
1524 | |||
1525 | if (vfh && vfh->ctrl_handler) | ||
1526 | return v4l2_g_ctrl(vfh->ctrl_handler, p); | ||
1527 | if (vfd->ctrl_handler) | ||
1528 | return v4l2_g_ctrl(vfd->ctrl_handler, p); | ||
1529 | if (ops->vidioc_g_ctrl) | ||
1530 | return ops->vidioc_g_ctrl(file, fh, p); | ||
1531 | if (ops->vidioc_g_ext_ctrls == NULL) | ||
1532 | return -ENOTTY; | ||
1533 | |||
1534 | ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); | ||
1535 | ctrls.count = 1; | ||
1536 | ctrls.controls = &ctrl; | ||
1537 | ctrl.id = p->id; | ||
1538 | ctrl.value = p->value; | ||
1539 | if (check_ext_ctrls(&ctrls, 1)) { | ||
1540 | int ret = ops->vidioc_g_ext_ctrls(file, fh, &ctrls); | ||
1541 | |||
1542 | if (ret == 0) | ||
1543 | p->value = ctrl.value; | ||
1544 | return ret; | ||
1638 | } | 1545 | } |
1639 | case VIDIOC_TRY_ENCODER_CMD: | 1546 | return -EINVAL; |
1640 | { | 1547 | } |
1641 | struct v4l2_encoder_cmd *p = arg; | ||
1642 | 1548 | ||
1643 | ret = ops->vidioc_try_encoder_cmd(file, fh, p); | 1549 | static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, |
1644 | if (!ret) | 1550 | struct file *file, void *fh, void *arg) |
1645 | dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); | 1551 | { |
1646 | break; | 1552 | struct video_device *vfd = video_devdata(file); |
1647 | } | 1553 | struct v4l2_control *p = arg; |
1648 | case VIDIOC_DECODER_CMD: | 1554 | struct v4l2_fh *vfh = fh; |
1649 | { | 1555 | struct v4l2_ext_controls ctrls; |
1650 | struct v4l2_decoder_cmd *p = arg; | 1556 | struct v4l2_ext_control ctrl; |
1557 | |||
1558 | if (vfh && vfh->ctrl_handler) | ||
1559 | return v4l2_s_ctrl(vfh, vfh->ctrl_handler, p); | ||
1560 | if (vfd->ctrl_handler) | ||
1561 | return v4l2_s_ctrl(NULL, vfd->ctrl_handler, p); | ||
1562 | if (ops->vidioc_s_ctrl) | ||
1563 | return ops->vidioc_s_ctrl(file, fh, p); | ||
1564 | if (ops->vidioc_s_ext_ctrls == NULL) | ||
1565 | return -ENOTTY; | ||
1566 | |||
1567 | ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); | ||
1568 | ctrls.count = 1; | ||
1569 | ctrls.controls = &ctrl; | ||
1570 | ctrl.id = p->id; | ||
1571 | ctrl.value = p->value; | ||
1572 | if (check_ext_ctrls(&ctrls, 1)) | ||
1573 | return ops->vidioc_s_ext_ctrls(file, fh, &ctrls); | ||
1574 | return -EINVAL; | ||
1575 | } | ||
1651 | 1576 | ||
1652 | ret = ops->vidioc_decoder_cmd(file, fh, p); | 1577 | static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops, |
1653 | if (!ret) | 1578 | struct file *file, void *fh, void *arg) |
1654 | dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); | 1579 | { |
1655 | break; | 1580 | struct video_device *vfd = video_devdata(file); |
1656 | } | 1581 | struct v4l2_ext_controls *p = arg; |
1657 | case VIDIOC_TRY_DECODER_CMD: | 1582 | struct v4l2_fh *vfh = fh; |
1658 | { | 1583 | |
1659 | struct v4l2_decoder_cmd *p = arg; | 1584 | p->error_idx = p->count; |
1585 | if (vfh && vfh->ctrl_handler) | ||
1586 | return v4l2_g_ext_ctrls(vfh->ctrl_handler, p); | ||
1587 | if (vfd->ctrl_handler) | ||
1588 | return v4l2_g_ext_ctrls(vfd->ctrl_handler, p); | ||
1589 | if (ops->vidioc_g_ext_ctrls == NULL) | ||
1590 | return -ENOTTY; | ||
1591 | return check_ext_ctrls(p, 0) ? ops->vidioc_g_ext_ctrls(file, fh, p) : | ||
1592 | -EINVAL; | ||
1593 | } | ||
1660 | 1594 | ||
1661 | ret = ops->vidioc_try_decoder_cmd(file, fh, p); | 1595 | static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops, |
1662 | if (!ret) | 1596 | struct file *file, void *fh, void *arg) |
1663 | dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); | 1597 | { |
1664 | break; | 1598 | struct video_device *vfd = video_devdata(file); |
1665 | } | 1599 | struct v4l2_ext_controls *p = arg; |
1666 | case VIDIOC_G_PARM: | 1600 | struct v4l2_fh *vfh = fh; |
1667 | { | 1601 | |
1668 | struct v4l2_streamparm *p = arg; | 1602 | p->error_idx = p->count; |
1603 | if (vfh && vfh->ctrl_handler) | ||
1604 | return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, p); | ||
1605 | if (vfd->ctrl_handler) | ||
1606 | return v4l2_s_ext_ctrls(NULL, vfd->ctrl_handler, p); | ||
1607 | if (ops->vidioc_s_ext_ctrls == NULL) | ||
1608 | return -ENOTTY; | ||
1609 | return check_ext_ctrls(p, 0) ? ops->vidioc_s_ext_ctrls(file, fh, p) : | ||
1610 | -EINVAL; | ||
1611 | } | ||
1669 | 1612 | ||
1670 | if (ops->vidioc_g_parm) { | 1613 | static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops, |
1671 | ret = check_fmt(ops, p->type); | 1614 | struct file *file, void *fh, void *arg) |
1672 | if (ret) | 1615 | { |
1673 | break; | 1616 | struct video_device *vfd = video_devdata(file); |
1674 | ret = ops->vidioc_g_parm(file, fh, p); | 1617 | struct v4l2_ext_controls *p = arg; |
1675 | } else { | 1618 | struct v4l2_fh *vfh = fh; |
1676 | v4l2_std_id std = vfd->current_norm; | 1619 | |
1620 | p->error_idx = p->count; | ||
1621 | if (vfh && vfh->ctrl_handler) | ||
1622 | return v4l2_try_ext_ctrls(vfh->ctrl_handler, p); | ||
1623 | if (vfd->ctrl_handler) | ||
1624 | return v4l2_try_ext_ctrls(vfd->ctrl_handler, p); | ||
1625 | if (ops->vidioc_try_ext_ctrls == NULL) | ||
1626 | return -ENOTTY; | ||
1627 | return check_ext_ctrls(p, 0) ? ops->vidioc_try_ext_ctrls(file, fh, p) : | ||
1628 | -EINVAL; | ||
1629 | } | ||
1677 | 1630 | ||
1678 | ret = -EINVAL; | 1631 | static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, |
1679 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1632 | struct file *file, void *fh, void *arg) |
1680 | break; | 1633 | { |
1634 | struct v4l2_crop *p = arg; | ||
1635 | struct v4l2_selection s = { | ||
1636 | .type = p->type, | ||
1637 | }; | ||
1638 | int ret; | ||
1639 | |||
1640 | if (ops->vidioc_g_crop) | ||
1641 | return ops->vidioc_g_crop(file, fh, p); | ||
1642 | /* simulate capture crop using selection api */ | ||
1643 | |||
1644 | /* crop means compose for output devices */ | ||
1645 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1646 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1647 | else | ||
1648 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1649 | |||
1650 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1651 | |||
1652 | /* copying results to old structure on success */ | ||
1653 | if (!ret) | ||
1654 | p->c = s.r; | ||
1655 | return ret; | ||
1656 | } | ||
1681 | 1657 | ||
1682 | ret = 0; | 1658 | static int v4l_s_crop(const struct v4l2_ioctl_ops *ops, |
1683 | p->parm.capture.readbuffers = 2; | 1659 | struct file *file, void *fh, void *arg) |
1684 | if (ops->vidioc_g_std) | 1660 | { |
1685 | ret = ops->vidioc_g_std(file, fh, &std); | 1661 | struct v4l2_crop *p = arg; |
1686 | if (ret == 0) | 1662 | struct v4l2_selection s = { |
1687 | v4l2_video_std_frame_period(std, | 1663 | .type = p->type, |
1688 | &p->parm.capture.timeperframe); | 1664 | .r = p->c, |
1689 | } | 1665 | }; |
1666 | |||
1667 | if (ops->vidioc_s_crop) | ||
1668 | return ops->vidioc_s_crop(file, fh, p); | ||
1669 | /* simulate capture crop using selection api */ | ||
1670 | |||
1671 | /* crop means compose for output devices */ | ||
1672 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1673 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1674 | else | ||
1675 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1676 | |||
1677 | return ops->vidioc_s_selection(file, fh, &s); | ||
1678 | } | ||
1690 | 1679 | ||
1691 | dbgarg(cmd, "type=%d\n", p->type); | 1680 | static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, |
1692 | break; | 1681 | struct file *file, void *fh, void *arg) |
1693 | } | 1682 | { |
1694 | case VIDIOC_S_PARM: | 1683 | struct v4l2_cropcap *p = arg; |
1695 | { | 1684 | struct v4l2_selection s = { .type = p->type }; |
1696 | struct v4l2_streamparm *p = arg; | 1685 | int ret; |
1697 | 1686 | ||
1698 | ret = check_fmt(ops, p->type); | 1687 | if (ops->vidioc_cropcap) |
1699 | if (ret) | 1688 | return ops->vidioc_cropcap(file, fh, p); |
1700 | break; | ||
1701 | 1689 | ||
1702 | dbgarg(cmd, "type=%d\n", p->type); | 1690 | /* obtaining bounds */ |
1703 | ret = ops->vidioc_s_parm(file, fh, p); | 1691 | if (V4L2_TYPE_IS_OUTPUT(p->type)) |
1704 | break; | 1692 | s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; |
1705 | } | 1693 | else |
1706 | case VIDIOC_G_TUNER: | 1694 | s.target = V4L2_SEL_TGT_CROP_BOUNDS; |
1707 | { | ||
1708 | struct v4l2_tuner *p = arg; | ||
1709 | 1695 | ||
1710 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1696 | ret = ops->vidioc_g_selection(file, fh, &s); |
1711 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1697 | if (ret) |
1712 | ret = ops->vidioc_g_tuner(file, fh, p); | 1698 | return ret; |
1713 | if (!ret) | 1699 | p->bounds = s.r; |
1714 | dbgarg(cmd, "index=%d, name=%s, type=%d, " | ||
1715 | "capability=0x%x, rangelow=%d, " | ||
1716 | "rangehigh=%d, signal=%d, afc=%d, " | ||
1717 | "rxsubchans=0x%x, audmode=%d\n", | ||
1718 | p->index, p->name, p->type, | ||
1719 | p->capability, p->rangelow, | ||
1720 | p->rangehigh, p->signal, p->afc, | ||
1721 | p->rxsubchans, p->audmode); | ||
1722 | break; | ||
1723 | } | ||
1724 | case VIDIOC_S_TUNER: | ||
1725 | { | ||
1726 | struct v4l2_tuner *p = arg; | ||
1727 | 1700 | ||
1728 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1701 | /* obtaining defrect */ |
1729 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1702 | if (V4L2_TYPE_IS_OUTPUT(p->type)) |
1730 | dbgarg(cmd, "index=%d, name=%s, type=%d, " | 1703 | s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; |
1731 | "capability=0x%x, rangelow=%d, " | 1704 | else |
1732 | "rangehigh=%d, signal=%d, afc=%d, " | 1705 | s.target = V4L2_SEL_TGT_CROP_DEFAULT; |
1733 | "rxsubchans=0x%x, audmode=%d\n", | ||
1734 | p->index, p->name, p->type, | ||
1735 | p->capability, p->rangelow, | ||
1736 | p->rangehigh, p->signal, p->afc, | ||
1737 | p->rxsubchans, p->audmode); | ||
1738 | ret = ops->vidioc_s_tuner(file, fh, p); | ||
1739 | break; | ||
1740 | } | ||
1741 | case VIDIOC_G_FREQUENCY: | ||
1742 | { | ||
1743 | struct v4l2_frequency *p = arg; | ||
1744 | 1706 | ||
1745 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1707 | ret = ops->vidioc_g_selection(file, fh, &s); |
1746 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1708 | if (ret) |
1747 | ret = ops->vidioc_g_frequency(file, fh, p); | 1709 | return ret; |
1748 | if (!ret) | 1710 | p->defrect = s.r; |
1749 | dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n", | ||
1750 | p->tuner, p->type, p->frequency); | ||
1751 | break; | ||
1752 | } | ||
1753 | case VIDIOC_S_FREQUENCY: | ||
1754 | { | ||
1755 | struct v4l2_frequency *p = arg; | ||
1756 | enum v4l2_tuner_type type; | ||
1757 | 1711 | ||
1758 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1712 | /* setting trivial pixelaspect */ |
1759 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1713 | p->pixelaspect.numerator = 1; |
1760 | dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n", | 1714 | p->pixelaspect.denominator = 1; |
1761 | p->tuner, p->type, p->frequency); | 1715 | return 0; |
1762 | if (p->type != type) | 1716 | } |
1763 | ret = -EINVAL; | ||
1764 | else | ||
1765 | ret = ops->vidioc_s_frequency(file, fh, p); | ||
1766 | break; | ||
1767 | } | ||
1768 | case VIDIOC_G_SLICED_VBI_CAP: | ||
1769 | { | ||
1770 | struct v4l2_sliced_vbi_cap *p = arg; | ||
1771 | 1717 | ||
1772 | /* Clear up to type, everything after type is zerod already */ | 1718 | static int v4l_log_status(const struct v4l2_ioctl_ops *ops, |
1773 | memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type)); | 1719 | struct file *file, void *fh, void *arg) |
1720 | { | ||
1721 | struct video_device *vfd = video_devdata(file); | ||
1722 | int ret; | ||
1723 | |||
1724 | if (vfd->v4l2_dev) | ||
1725 | pr_info("%s: ================= START STATUS =================\n", | ||
1726 | vfd->v4l2_dev->name); | ||
1727 | ret = ops->vidioc_log_status(file, fh); | ||
1728 | if (vfd->v4l2_dev) | ||
1729 | pr_info("%s: ================== END STATUS ==================\n", | ||
1730 | vfd->v4l2_dev->name); | ||
1731 | return ret; | ||
1732 | } | ||
1774 | 1733 | ||
1775 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1734 | static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, |
1776 | ret = ops->vidioc_g_sliced_vbi_cap(file, fh, p); | 1735 | struct file *file, void *fh, void *arg) |
1777 | if (!ret) | 1736 | { |
1778 | dbgarg2("service_set=%d\n", p->service_set); | ||
1779 | break; | ||
1780 | } | ||
1781 | case VIDIOC_LOG_STATUS: | ||
1782 | { | ||
1783 | if (vfd->v4l2_dev) | ||
1784 | pr_info("%s: ================= START STATUS =================\n", | ||
1785 | vfd->v4l2_dev->name); | ||
1786 | ret = ops->vidioc_log_status(file, fh); | ||
1787 | if (vfd->v4l2_dev) | ||
1788 | pr_info("%s: ================== END STATUS ==================\n", | ||
1789 | vfd->v4l2_dev->name); | ||
1790 | break; | ||
1791 | } | ||
1792 | case VIDIOC_DBG_G_REGISTER: | ||
1793 | { | ||
1794 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1737 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1795 | struct v4l2_dbg_register *p = arg; | 1738 | struct v4l2_dbg_register *p = arg; |
1796 | 1739 | ||
1797 | if (!capable(CAP_SYS_ADMIN)) | 1740 | if (!capable(CAP_SYS_ADMIN)) |
1798 | ret = -EPERM; | 1741 | return -EPERM; |
1799 | else | 1742 | return ops->vidioc_g_register(file, fh, p); |
1800 | ret = ops->vidioc_g_register(file, fh, p); | 1743 | #else |
1744 | return -ENOTTY; | ||
1801 | #endif | 1745 | #endif |
1802 | break; | 1746 | } |
1803 | } | 1747 | |
1804 | case VIDIOC_DBG_S_REGISTER: | 1748 | static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, |
1805 | { | 1749 | struct file *file, void *fh, void *arg) |
1750 | { | ||
1806 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1751 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1807 | struct v4l2_dbg_register *p = arg; | 1752 | struct v4l2_dbg_register *p = arg; |
1808 | 1753 | ||
1809 | if (!capable(CAP_SYS_ADMIN)) | 1754 | if (!capable(CAP_SYS_ADMIN)) |
1810 | ret = -EPERM; | 1755 | return -EPERM; |
1811 | else | 1756 | return ops->vidioc_s_register(file, fh, p); |
1812 | ret = ops->vidioc_s_register(file, fh, p); | 1757 | #else |
1758 | return -ENOTTY; | ||
1813 | #endif | 1759 | #endif |
1814 | break; | 1760 | } |
1815 | } | ||
1816 | case VIDIOC_DBG_G_CHIP_IDENT: | ||
1817 | { | ||
1818 | struct v4l2_dbg_chip_ident *p = arg; | ||
1819 | |||
1820 | p->ident = V4L2_IDENT_NONE; | ||
1821 | p->revision = 0; | ||
1822 | ret = ops->vidioc_g_chip_ident(file, fh, p); | ||
1823 | if (!ret) | ||
1824 | dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); | ||
1825 | break; | ||
1826 | } | ||
1827 | case VIDIOC_S_HW_FREQ_SEEK: | ||
1828 | { | ||
1829 | struct v4l2_hw_freq_seek *p = arg; | ||
1830 | enum v4l2_tuner_type type; | ||
1831 | 1761 | ||
1832 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1762 | static int v4l_dbg_g_chip_ident(const struct v4l2_ioctl_ops *ops, |
1833 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1763 | struct file *file, void *fh, void *arg) |
1834 | dbgarg(cmd, | 1764 | { |
1835 | "tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u\n", | 1765 | struct v4l2_dbg_chip_ident *p = arg; |
1836 | p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing); | ||
1837 | if (p->type != type) | ||
1838 | ret = -EINVAL; | ||
1839 | else | ||
1840 | ret = ops->vidioc_s_hw_freq_seek(file, fh, p); | ||
1841 | break; | ||
1842 | } | ||
1843 | case VIDIOC_ENUM_FRAMESIZES: | ||
1844 | { | ||
1845 | struct v4l2_frmsizeenum *p = arg; | ||
1846 | 1766 | ||
1847 | ret = ops->vidioc_enum_framesizes(file, fh, p); | 1767 | p->ident = V4L2_IDENT_NONE; |
1848 | dbgarg(cmd, | 1768 | p->revision = 0; |
1849 | "index=%d, pixelformat=%c%c%c%c, type=%d ", | 1769 | return ops->vidioc_g_chip_ident(file, fh, p); |
1850 | p->index, | 1770 | } |
1851 | (p->pixel_format & 0xff), | ||
1852 | (p->pixel_format >> 8) & 0xff, | ||
1853 | (p->pixel_format >> 16) & 0xff, | ||
1854 | (p->pixel_format >> 24) & 0xff, | ||
1855 | p->type); | ||
1856 | switch (p->type) { | ||
1857 | case V4L2_FRMSIZE_TYPE_DISCRETE: | ||
1858 | dbgarg3("width = %d, height=%d\n", | ||
1859 | p->discrete.width, p->discrete.height); | ||
1860 | break; | ||
1861 | case V4L2_FRMSIZE_TYPE_STEPWISE: | ||
1862 | dbgarg3("min %dx%d, max %dx%d, step %dx%d\n", | ||
1863 | p->stepwise.min_width, p->stepwise.min_height, | ||
1864 | p->stepwise.step_width, p->stepwise.step_height, | ||
1865 | p->stepwise.max_width, p->stepwise.max_height); | ||
1866 | break; | ||
1867 | case V4L2_FRMSIZE_TYPE_CONTINUOUS: | ||
1868 | dbgarg3("continuous\n"); | ||
1869 | break; | ||
1870 | default: | ||
1871 | dbgarg3("- Unknown type!\n"); | ||
1872 | } | ||
1873 | 1771 | ||
1874 | break; | 1772 | static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, |
1875 | } | 1773 | struct file *file, void *fh, void *arg) |
1876 | case VIDIOC_ENUM_FRAMEINTERVALS: | 1774 | { |
1877 | { | 1775 | return v4l2_event_dequeue(fh, arg, file->f_flags & O_NONBLOCK); |
1878 | struct v4l2_frmivalenum *p = arg; | 1776 | } |
1879 | |||
1880 | ret = ops->vidioc_enum_frameintervals(file, fh, p); | ||
1881 | dbgarg(cmd, | ||
1882 | "index=%d, pixelformat=%d, width=%d, height=%d, type=%d ", | ||
1883 | p->index, p->pixel_format, | ||
1884 | p->width, p->height, p->type); | ||
1885 | switch (p->type) { | ||
1886 | case V4L2_FRMIVAL_TYPE_DISCRETE: | ||
1887 | dbgarg2("fps=%d/%d\n", | ||
1888 | p->discrete.numerator, | ||
1889 | p->discrete.denominator); | ||
1890 | break; | ||
1891 | case V4L2_FRMIVAL_TYPE_STEPWISE: | ||
1892 | dbgarg2("min=%d/%d, max=%d/%d, step=%d/%d\n", | ||
1893 | p->stepwise.min.numerator, | ||
1894 | p->stepwise.min.denominator, | ||
1895 | p->stepwise.max.numerator, | ||
1896 | p->stepwise.max.denominator, | ||
1897 | p->stepwise.step.numerator, | ||
1898 | p->stepwise.step.denominator); | ||
1899 | break; | ||
1900 | case V4L2_FRMIVAL_TYPE_CONTINUOUS: | ||
1901 | dbgarg2("continuous\n"); | ||
1902 | break; | ||
1903 | default: | ||
1904 | dbgarg2("- Unknown type!\n"); | ||
1905 | } | ||
1906 | break; | ||
1907 | } | ||
1908 | case VIDIOC_ENUM_DV_PRESETS: | ||
1909 | { | ||
1910 | struct v4l2_dv_enum_preset *p = arg; | ||
1911 | |||
1912 | ret = ops->vidioc_enum_dv_presets(file, fh, p); | ||
1913 | if (!ret) | ||
1914 | dbgarg(cmd, | ||
1915 | "index=%d, preset=%d, name=%s, width=%d," | ||
1916 | " height=%d ", | ||
1917 | p->index, p->preset, p->name, p->width, | ||
1918 | p->height); | ||
1919 | break; | ||
1920 | } | ||
1921 | case VIDIOC_S_DV_PRESET: | ||
1922 | { | ||
1923 | struct v4l2_dv_preset *p = arg; | ||
1924 | 1777 | ||
1925 | dbgarg(cmd, "preset=%d\n", p->preset); | 1778 | static int v4l_subscribe_event(const struct v4l2_ioctl_ops *ops, |
1926 | ret = ops->vidioc_s_dv_preset(file, fh, p); | 1779 | struct file *file, void *fh, void *arg) |
1927 | break; | 1780 | { |
1928 | } | 1781 | return ops->vidioc_subscribe_event(fh, arg); |
1929 | case VIDIOC_G_DV_PRESET: | 1782 | } |
1930 | { | ||
1931 | struct v4l2_dv_preset *p = arg; | ||
1932 | 1783 | ||
1933 | ret = ops->vidioc_g_dv_preset(file, fh, p); | 1784 | static int v4l_unsubscribe_event(const struct v4l2_ioctl_ops *ops, |
1934 | if (!ret) | 1785 | struct file *file, void *fh, void *arg) |
1935 | dbgarg(cmd, "preset=%d\n", p->preset); | 1786 | { |
1936 | break; | 1787 | return ops->vidioc_unsubscribe_event(fh, arg); |
1937 | } | 1788 | } |
1938 | case VIDIOC_QUERY_DV_PRESET: | ||
1939 | { | ||
1940 | struct v4l2_dv_preset *p = arg; | ||
1941 | 1789 | ||
1942 | ret = ops->vidioc_query_dv_preset(file, fh, p); | 1790 | static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops, |
1943 | if (!ret) | 1791 | struct file *file, void *fh, void *arg) |
1944 | dbgarg(cmd, "preset=%d\n", p->preset); | 1792 | { |
1945 | break; | 1793 | struct v4l2_sliced_vbi_cap *p = arg; |
1946 | } | ||
1947 | case VIDIOC_S_DV_TIMINGS: | ||
1948 | { | ||
1949 | struct v4l2_dv_timings *p = arg; | ||
1950 | |||
1951 | dbgtimings(vfd, p); | ||
1952 | switch (p->type) { | ||
1953 | case V4L2_DV_BT_656_1120: | ||
1954 | ret = ops->vidioc_s_dv_timings(file, fh, p); | ||
1955 | break; | ||
1956 | default: | ||
1957 | ret = -EINVAL; | ||
1958 | break; | ||
1959 | } | ||
1960 | break; | ||
1961 | } | ||
1962 | case VIDIOC_G_DV_TIMINGS: | ||
1963 | { | ||
1964 | struct v4l2_dv_timings *p = arg; | ||
1965 | 1794 | ||
1966 | ret = ops->vidioc_g_dv_timings(file, fh, p); | 1795 | /* Clear up to type, everything after type is zeroed already */ |
1967 | if (!ret) | 1796 | memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type)); |
1968 | dbgtimings(vfd, p); | ||
1969 | break; | ||
1970 | } | ||
1971 | case VIDIOC_ENUM_DV_TIMINGS: | ||
1972 | { | ||
1973 | struct v4l2_enum_dv_timings *p = arg; | ||
1974 | 1797 | ||
1975 | if (!ops->vidioc_enum_dv_timings) | 1798 | return ops->vidioc_g_sliced_vbi_cap(file, fh, p); |
1976 | break; | 1799 | } |
1977 | 1800 | ||
1978 | ret = ops->vidioc_enum_dv_timings(file, fh, p); | 1801 | struct v4l2_ioctl_info { |
1979 | if (!ret) { | 1802 | unsigned int ioctl; |
1980 | dbgarg(cmd, "index=%d: ", p->index); | 1803 | u32 flags; |
1981 | dbgtimings(vfd, &p->timings); | 1804 | const char * const name; |
1982 | } | 1805 | union { |
1983 | break; | 1806 | u32 offset; |
1807 | int (*func)(const struct v4l2_ioctl_ops *ops, | ||
1808 | struct file *file, void *fh, void *p); | ||
1809 | }; | ||
1810 | void (*debug)(const void *arg, bool write_only); | ||
1811 | }; | ||
1812 | |||
1813 | /* This control needs a priority check */ | ||
1814 | #define INFO_FL_PRIO (1 << 0) | ||
1815 | /* This control can be valid if the filehandle passes a control handler. */ | ||
1816 | #define INFO_FL_CTRL (1 << 1) | ||
1817 | /* This is a standard ioctl, no need for special code */ | ||
1818 | #define INFO_FL_STD (1 << 2) | ||
1819 | /* This is ioctl has its own function */ | ||
1820 | #define INFO_FL_FUNC (1 << 3) | ||
1821 | /* Queuing ioctl */ | ||
1822 | #define INFO_FL_QUEUE (1 << 4) | ||
1823 | /* Zero struct from after the field to the end */ | ||
1824 | #define INFO_FL_CLEAR(v4l2_struct, field) \ | ||
1825 | ((offsetof(struct v4l2_struct, field) + \ | ||
1826 | sizeof(((struct v4l2_struct *)0)->field)) << 16) | ||
1827 | #define INFO_FL_CLEAR_MASK (_IOC_SIZEMASK << 16) | ||
1828 | |||
1829 | #define IOCTL_INFO_STD(_ioctl, _vidioc, _debug, _flags) \ | ||
1830 | [_IOC_NR(_ioctl)] = { \ | ||
1831 | .ioctl = _ioctl, \ | ||
1832 | .flags = _flags | INFO_FL_STD, \ | ||
1833 | .name = #_ioctl, \ | ||
1834 | .offset = offsetof(struct v4l2_ioctl_ops, _vidioc), \ | ||
1835 | .debug = _debug, \ | ||
1836 | } | ||
1837 | |||
1838 | #define IOCTL_INFO_FNC(_ioctl, _func, _debug, _flags) \ | ||
1839 | [_IOC_NR(_ioctl)] = { \ | ||
1840 | .ioctl = _ioctl, \ | ||
1841 | .flags = _flags | INFO_FL_FUNC, \ | ||
1842 | .name = #_ioctl, \ | ||
1843 | .func = _func, \ | ||
1844 | .debug = _debug, \ | ||
1984 | } | 1845 | } |
1985 | case VIDIOC_QUERY_DV_TIMINGS: | ||
1986 | { | ||
1987 | struct v4l2_dv_timings *p = arg; | ||
1988 | 1846 | ||
1989 | if (!ops->vidioc_query_dv_timings) | 1847 | static struct v4l2_ioctl_info v4l2_ioctls[] = { |
1990 | break; | 1848 | IOCTL_INFO_FNC(VIDIOC_QUERYCAP, v4l_querycap, v4l_print_querycap, 0), |
1849 | IOCTL_INFO_FNC(VIDIOC_ENUM_FMT, v4l_enum_fmt, v4l_print_fmtdesc, INFO_FL_CLEAR(v4l2_fmtdesc, type)), | ||
1850 | IOCTL_INFO_FNC(VIDIOC_G_FMT, v4l_g_fmt, v4l_print_format, INFO_FL_CLEAR(v4l2_format, type)), | ||
1851 | IOCTL_INFO_FNC(VIDIOC_S_FMT, v4l_s_fmt, v4l_print_format, INFO_FL_PRIO), | ||
1852 | IOCTL_INFO_FNC(VIDIOC_REQBUFS, v4l_reqbufs, v4l_print_requestbuffers, INFO_FL_PRIO | INFO_FL_QUEUE), | ||
1853 | IOCTL_INFO_FNC(VIDIOC_QUERYBUF, v4l_querybuf, v4l_print_buffer, INFO_FL_QUEUE | INFO_FL_CLEAR(v4l2_buffer, length)), | ||
1854 | IOCTL_INFO_STD(VIDIOC_G_FBUF, vidioc_g_fbuf, v4l_print_framebuffer, 0), | ||
1855 | IOCTL_INFO_STD(VIDIOC_S_FBUF, vidioc_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO), | ||
1856 | IOCTL_INFO_STD(VIDIOC_OVERLAY, vidioc_overlay, v4l_print_u32, INFO_FL_PRIO), | ||
1857 | IOCTL_INFO_FNC(VIDIOC_QBUF, v4l_qbuf, v4l_print_buffer, INFO_FL_QUEUE), | ||
1858 | IOCTL_INFO_FNC(VIDIOC_DQBUF, v4l_dqbuf, v4l_print_buffer, INFO_FL_QUEUE), | ||
1859 | IOCTL_INFO_FNC(VIDIOC_STREAMON, v4l_streamon, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), | ||
1860 | IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), | ||
1861 | IOCTL_INFO_FNC(VIDIOC_G_PARM, v4l_g_parm, v4l_print_streamparm, INFO_FL_CLEAR(v4l2_streamparm, type)), | ||
1862 | IOCTL_INFO_FNC(VIDIOC_S_PARM, v4l_s_parm, v4l_print_streamparm, INFO_FL_PRIO), | ||
1863 | IOCTL_INFO_FNC(VIDIOC_G_STD, v4l_g_std, v4l_print_std, 0), | ||
1864 | IOCTL_INFO_FNC(VIDIOC_S_STD, v4l_s_std, v4l_print_std, INFO_FL_PRIO), | ||
1865 | IOCTL_INFO_FNC(VIDIOC_ENUMSTD, v4l_enumstd, v4l_print_standard, INFO_FL_CLEAR(v4l2_standard, index)), | ||
1866 | IOCTL_INFO_FNC(VIDIOC_ENUMINPUT, v4l_enuminput, v4l_print_enuminput, INFO_FL_CLEAR(v4l2_input, index)), | ||
1867 | IOCTL_INFO_FNC(VIDIOC_G_CTRL, v4l_g_ctrl, v4l_print_control, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_control, id)), | ||
1868 | IOCTL_INFO_FNC(VIDIOC_S_CTRL, v4l_s_ctrl, v4l_print_control, INFO_FL_PRIO | INFO_FL_CTRL), | ||
1869 | IOCTL_INFO_FNC(VIDIOC_G_TUNER, v4l_g_tuner, v4l_print_tuner, INFO_FL_CLEAR(v4l2_tuner, index)), | ||
1870 | IOCTL_INFO_FNC(VIDIOC_S_TUNER, v4l_s_tuner, v4l_print_tuner, INFO_FL_PRIO), | ||
1871 | IOCTL_INFO_STD(VIDIOC_G_AUDIO, vidioc_g_audio, v4l_print_audio, 0), | ||
1872 | IOCTL_INFO_STD(VIDIOC_S_AUDIO, vidioc_s_audio, v4l_print_audio, INFO_FL_PRIO), | ||
1873 | IOCTL_INFO_FNC(VIDIOC_QUERYCTRL, v4l_queryctrl, v4l_print_queryctrl, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_queryctrl, id)), | ||
1874 | IOCTL_INFO_FNC(VIDIOC_QUERYMENU, v4l_querymenu, v4l_print_querymenu, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_querymenu, index)), | ||
1875 | IOCTL_INFO_STD(VIDIOC_G_INPUT, vidioc_g_input, v4l_print_u32, 0), | ||
1876 | IOCTL_INFO_FNC(VIDIOC_S_INPUT, v4l_s_input, v4l_print_u32, INFO_FL_PRIO), | ||
1877 | IOCTL_INFO_STD(VIDIOC_G_OUTPUT, vidioc_g_output, v4l_print_u32, 0), | ||
1878 | IOCTL_INFO_FNC(VIDIOC_S_OUTPUT, v4l_s_output, v4l_print_u32, INFO_FL_PRIO), | ||
1879 | IOCTL_INFO_FNC(VIDIOC_ENUMOUTPUT, v4l_enumoutput, v4l_print_enumoutput, INFO_FL_CLEAR(v4l2_output, index)), | ||
1880 | IOCTL_INFO_STD(VIDIOC_G_AUDOUT, vidioc_g_audout, v4l_print_audioout, 0), | ||
1881 | IOCTL_INFO_STD(VIDIOC_S_AUDOUT, vidioc_s_audout, v4l_print_audioout, INFO_FL_PRIO), | ||
1882 | IOCTL_INFO_STD(VIDIOC_G_MODULATOR, vidioc_g_modulator, v4l_print_modulator, INFO_FL_CLEAR(v4l2_modulator, index)), | ||
1883 | IOCTL_INFO_STD(VIDIOC_S_MODULATOR, vidioc_s_modulator, v4l_print_modulator, INFO_FL_PRIO), | ||
1884 | IOCTL_INFO_FNC(VIDIOC_G_FREQUENCY, v4l_g_frequency, v4l_print_frequency, INFO_FL_CLEAR(v4l2_frequency, tuner)), | ||
1885 | IOCTL_INFO_FNC(VIDIOC_S_FREQUENCY, v4l_s_frequency, v4l_print_frequency, INFO_FL_PRIO), | ||
1886 | IOCTL_INFO_FNC(VIDIOC_CROPCAP, v4l_cropcap, v4l_print_cropcap, INFO_FL_CLEAR(v4l2_cropcap, type)), | ||
1887 | IOCTL_INFO_FNC(VIDIOC_G_CROP, v4l_g_crop, v4l_print_crop, INFO_FL_CLEAR(v4l2_crop, type)), | ||
1888 | IOCTL_INFO_FNC(VIDIOC_S_CROP, v4l_s_crop, v4l_print_crop, INFO_FL_PRIO), | ||
1889 | IOCTL_INFO_STD(VIDIOC_G_SELECTION, vidioc_g_selection, v4l_print_selection, 0), | ||
1890 | IOCTL_INFO_STD(VIDIOC_S_SELECTION, vidioc_s_selection, v4l_print_selection, INFO_FL_PRIO), | ||
1891 | IOCTL_INFO_STD(VIDIOC_G_JPEGCOMP, vidioc_g_jpegcomp, v4l_print_jpegcompression, 0), | ||
1892 | IOCTL_INFO_STD(VIDIOC_S_JPEGCOMP, vidioc_s_jpegcomp, v4l_print_jpegcompression, INFO_FL_PRIO), | ||
1893 | IOCTL_INFO_FNC(VIDIOC_QUERYSTD, v4l_querystd, v4l_print_std, 0), | ||
1894 | IOCTL_INFO_FNC(VIDIOC_TRY_FMT, v4l_try_fmt, v4l_print_format, 0), | ||
1895 | IOCTL_INFO_STD(VIDIOC_ENUMAUDIO, vidioc_enumaudio, v4l_print_audio, INFO_FL_CLEAR(v4l2_audio, index)), | ||
1896 | IOCTL_INFO_STD(VIDIOC_ENUMAUDOUT, vidioc_enumaudout, v4l_print_audioout, INFO_FL_CLEAR(v4l2_audioout, index)), | ||
1897 | IOCTL_INFO_FNC(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0), | ||
1898 | IOCTL_INFO_FNC(VIDIOC_S_PRIORITY, v4l_s_priority, v4l_print_u32, INFO_FL_PRIO), | ||
1899 | IOCTL_INFO_FNC(VIDIOC_G_SLICED_VBI_CAP, v4l_g_sliced_vbi_cap, v4l_print_sliced_vbi_cap, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)), | ||
1900 | IOCTL_INFO_FNC(VIDIOC_LOG_STATUS, v4l_log_status, v4l_print_newline, 0), | ||
1901 | IOCTL_INFO_FNC(VIDIOC_G_EXT_CTRLS, v4l_g_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL), | ||
1902 | IOCTL_INFO_FNC(VIDIOC_S_EXT_CTRLS, v4l_s_ext_ctrls, v4l_print_ext_controls, INFO_FL_PRIO | INFO_FL_CTRL), | ||
1903 | IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, 0), | ||
1904 | IOCTL_INFO_STD(VIDIOC_ENUM_FRAMESIZES, vidioc_enum_framesizes, v4l_print_frmsizeenum, INFO_FL_CLEAR(v4l2_frmsizeenum, pixel_format)), | ||
1905 | IOCTL_INFO_STD(VIDIOC_ENUM_FRAMEINTERVALS, vidioc_enum_frameintervals, v4l_print_frmivalenum, INFO_FL_CLEAR(v4l2_frmivalenum, height)), | ||
1906 | IOCTL_INFO_STD(VIDIOC_G_ENC_INDEX, vidioc_g_enc_index, v4l_print_enc_idx, 0), | ||
1907 | IOCTL_INFO_STD(VIDIOC_ENCODER_CMD, vidioc_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_PRIO | INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), | ||
1908 | IOCTL_INFO_STD(VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), | ||
1909 | IOCTL_INFO_STD(VIDIOC_DECODER_CMD, vidioc_decoder_cmd, v4l_print_decoder_cmd, INFO_FL_PRIO), | ||
1910 | IOCTL_INFO_STD(VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd, v4l_print_decoder_cmd, 0), | ||
1911 | IOCTL_INFO_FNC(VIDIOC_DBG_S_REGISTER, v4l_dbg_s_register, v4l_print_dbg_register, 0), | ||
1912 | IOCTL_INFO_FNC(VIDIOC_DBG_G_REGISTER, v4l_dbg_g_register, v4l_print_dbg_register, 0), | ||
1913 | IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_IDENT, v4l_dbg_g_chip_ident, v4l_print_dbg_chip_ident, 0), | ||
1914 | IOCTL_INFO_FNC(VIDIOC_S_HW_FREQ_SEEK, v4l_s_hw_freq_seek, v4l_print_hw_freq_seek, INFO_FL_PRIO), | ||
1915 | IOCTL_INFO_STD(VIDIOC_ENUM_DV_PRESETS, vidioc_enum_dv_presets, v4l_print_dv_enum_presets, 0), | ||
1916 | IOCTL_INFO_STD(VIDIOC_S_DV_PRESET, vidioc_s_dv_preset, v4l_print_dv_preset, INFO_FL_PRIO), | ||
1917 | IOCTL_INFO_STD(VIDIOC_G_DV_PRESET, vidioc_g_dv_preset, v4l_print_dv_preset, 0), | ||
1918 | IOCTL_INFO_STD(VIDIOC_QUERY_DV_PRESET, vidioc_query_dv_preset, v4l_print_dv_preset, 0), | ||
1919 | IOCTL_INFO_STD(VIDIOC_S_DV_TIMINGS, vidioc_s_dv_timings, v4l_print_dv_timings, INFO_FL_PRIO), | ||
1920 | IOCTL_INFO_STD(VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings, v4l_print_dv_timings, 0), | ||
1921 | IOCTL_INFO_FNC(VIDIOC_DQEVENT, v4l_dqevent, v4l_print_event, 0), | ||
1922 | IOCTL_INFO_FNC(VIDIOC_SUBSCRIBE_EVENT, v4l_subscribe_event, v4l_print_event_subscription, 0), | ||
1923 | IOCTL_INFO_FNC(VIDIOC_UNSUBSCRIBE_EVENT, v4l_unsubscribe_event, v4l_print_event_subscription, 0), | ||
1924 | IOCTL_INFO_FNC(VIDIOC_CREATE_BUFS, v4l_create_bufs, v4l_print_create_buffers, INFO_FL_PRIO | INFO_FL_QUEUE), | ||
1925 | IOCTL_INFO_FNC(VIDIOC_PREPARE_BUF, v4l_prepare_buf, v4l_print_buffer, INFO_FL_QUEUE), | ||
1926 | IOCTL_INFO_STD(VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings, v4l_print_enum_dv_timings, 0), | ||
1927 | IOCTL_INFO_STD(VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings, v4l_print_dv_timings, 0), | ||
1928 | IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, v4l_print_dv_timings_cap, 0), | ||
1929 | }; | ||
1930 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | ||
1991 | 1931 | ||
1992 | ret = ops->vidioc_query_dv_timings(file, fh, p); | 1932 | bool v4l2_is_known_ioctl(unsigned int cmd) |
1993 | if (!ret) | 1933 | { |
1994 | dbgtimings(vfd, p); | 1934 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) |
1995 | break; | 1935 | return false; |
1996 | } | 1936 | return v4l2_ioctls[_IOC_NR(cmd)].ioctl == cmd; |
1997 | case VIDIOC_DV_TIMINGS_CAP: | 1937 | } |
1998 | { | ||
1999 | struct v4l2_dv_timings_cap *p = arg; | ||
2000 | 1938 | ||
2001 | if (!ops->vidioc_dv_timings_cap) | 1939 | struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned cmd) |
2002 | break; | 1940 | { |
1941 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) | ||
1942 | return vdev->lock; | ||
1943 | if (test_bit(_IOC_NR(cmd), vdev->disable_locking)) | ||
1944 | return NULL; | ||
1945 | if (vdev->queue && vdev->queue->lock && | ||
1946 | (v4l2_ioctls[_IOC_NR(cmd)].flags & INFO_FL_QUEUE)) | ||
1947 | return vdev->queue->lock; | ||
1948 | return vdev->lock; | ||
1949 | } | ||
2003 | 1950 | ||
2004 | ret = ops->vidioc_dv_timings_cap(file, fh, p); | 1951 | /* Common ioctl debug function. This function can be used by |
2005 | if (ret) | 1952 | external ioctl messages as well as internal V4L ioctl */ |
2006 | break; | 1953 | void v4l_printk_ioctl(const char *prefix, unsigned int cmd) |
2007 | switch (p->type) { | 1954 | { |
2008 | case V4L2_DV_BT_656_1120: | 1955 | const char *dir, *type; |
2009 | dbgarg(cmd, | ||
2010 | "type=%d, width=%u-%u, height=%u-%u, " | ||
2011 | "pixelclock=%llu-%llu, standards=%x, capabilities=%x ", | ||
2012 | p->type, | ||
2013 | p->bt.min_width, p->bt.max_width, | ||
2014 | p->bt.min_height, p->bt.max_height, | ||
2015 | p->bt.min_pixelclock, p->bt.max_pixelclock, | ||
2016 | p->bt.standards, p->bt.capabilities); | ||
2017 | break; | ||
2018 | default: | ||
2019 | dbgarg(cmd, "unknown type "); | ||
2020 | break; | ||
2021 | } | ||
2022 | break; | ||
2023 | } | ||
2024 | case VIDIOC_DQEVENT: | ||
2025 | { | ||
2026 | struct v4l2_event *ev = arg; | ||
2027 | 1956 | ||
2028 | ret = v4l2_event_dequeue(fh, ev, file->f_flags & O_NONBLOCK); | 1957 | if (prefix) |
2029 | if (ret < 0) { | 1958 | printk(KERN_DEBUG "%s: ", prefix); |
2030 | dbgarg(cmd, "no pending events?"); | ||
2031 | break; | ||
2032 | } | ||
2033 | dbgarg(cmd, | ||
2034 | "pending=%d, type=0x%8.8x, sequence=%d, " | ||
2035 | "timestamp=%lu.%9.9lu ", | ||
2036 | ev->pending, ev->type, ev->sequence, | ||
2037 | ev->timestamp.tv_sec, ev->timestamp.tv_nsec); | ||
2038 | break; | ||
2039 | } | ||
2040 | case VIDIOC_SUBSCRIBE_EVENT: | ||
2041 | { | ||
2042 | struct v4l2_event_subscription *sub = arg; | ||
2043 | 1959 | ||
2044 | ret = ops->vidioc_subscribe_event(fh, sub); | 1960 | switch (_IOC_TYPE(cmd)) { |
2045 | if (ret < 0) { | 1961 | case 'd': |
2046 | dbgarg(cmd, "failed, ret=%ld", ret); | 1962 | type = "v4l2_int"; |
2047 | break; | ||
2048 | } | ||
2049 | dbgarg(cmd, "type=0x%8.8x", sub->type); | ||
2050 | break; | 1963 | break; |
2051 | } | 1964 | case 'V': |
2052 | case VIDIOC_UNSUBSCRIBE_EVENT: | 1965 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) { |
2053 | { | 1966 | type = "v4l2"; |
2054 | struct v4l2_event_subscription *sub = arg; | ||
2055 | |||
2056 | ret = ops->vidioc_unsubscribe_event(fh, sub); | ||
2057 | if (ret < 0) { | ||
2058 | dbgarg(cmd, "failed, ret=%ld", ret); | ||
2059 | break; | 1967 | break; |
2060 | } | 1968 | } |
2061 | dbgarg(cmd, "type=0x%8.8x", sub->type); | 1969 | pr_cont("%s", v4l2_ioctls[_IOC_NR(cmd)].name); |
1970 | return; | ||
1971 | default: | ||
1972 | type = "unknown"; | ||
2062 | break; | 1973 | break; |
2063 | } | 1974 | } |
2064 | case VIDIOC_CREATE_BUFS: | ||
2065 | { | ||
2066 | struct v4l2_create_buffers *create = arg; | ||
2067 | 1975 | ||
2068 | ret = check_fmt(ops, create->format.type); | 1976 | switch (_IOC_DIR(cmd)) { |
2069 | if (ret) | 1977 | case _IOC_NONE: dir = "--"; break; |
2070 | break; | 1978 | case _IOC_READ: dir = "r-"; break; |
1979 | case _IOC_WRITE: dir = "-w"; break; | ||
1980 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; | ||
1981 | default: dir = "*ERR*"; break; | ||
1982 | } | ||
1983 | pr_cont("%s ioctl '%c', dir=%s, #%d (0x%08x)", | ||
1984 | type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); | ||
1985 | } | ||
1986 | EXPORT_SYMBOL(v4l_printk_ioctl); | ||
2071 | 1987 | ||
2072 | ret = ops->vidioc_create_bufs(file, fh, create); | 1988 | static long __video_do_ioctl(struct file *file, |
1989 | unsigned int cmd, void *arg) | ||
1990 | { | ||
1991 | struct video_device *vfd = video_devdata(file); | ||
1992 | const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; | ||
1993 | bool write_only = false; | ||
1994 | struct v4l2_ioctl_info default_info; | ||
1995 | const struct v4l2_ioctl_info *info; | ||
1996 | void *fh = file->private_data; | ||
1997 | struct v4l2_fh *vfh = NULL; | ||
1998 | int use_fh_prio = 0; | ||
1999 | int debug = vfd->debug; | ||
2000 | long ret = -ENOTTY; | ||
2073 | 2001 | ||
2074 | dbgarg(cmd, "count=%d @ %d\n", create->count, create->index); | 2002 | if (ops == NULL) { |
2075 | break; | 2003 | pr_warn("%s: has no ioctl_ops.\n", |
2004 | video_device_node_name(vfd)); | ||
2005 | return ret; | ||
2076 | } | 2006 | } |
2077 | case VIDIOC_PREPARE_BUF: | ||
2078 | { | ||
2079 | struct v4l2_buffer *b = arg; | ||
2080 | 2007 | ||
2081 | ret = check_fmt(ops, b->type); | 2008 | if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { |
2082 | if (ret) | 2009 | vfh = file->private_data; |
2083 | break; | 2010 | use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); |
2011 | } | ||
2084 | 2012 | ||
2085 | ret = ops->vidioc_prepare_buf(file, fh, b); | 2013 | if (v4l2_is_known_ioctl(cmd)) { |
2014 | info = &v4l2_ioctls[_IOC_NR(cmd)]; | ||
2086 | 2015 | ||
2087 | dbgarg(cmd, "index=%d", b->index); | 2016 | if (!test_bit(_IOC_NR(cmd), vfd->valid_ioctls) && |
2088 | break; | 2017 | !((info->flags & INFO_FL_CTRL) && vfh && vfh->ctrl_handler)) |
2089 | } | 2018 | goto done; |
2090 | default: | ||
2091 | if (!ops->vidioc_default) | ||
2092 | break; | ||
2093 | ret = ops->vidioc_default(file, fh, use_fh_prio ? | ||
2094 | v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0, | ||
2095 | cmd, arg); | ||
2096 | break; | ||
2097 | } /* switch */ | ||
2098 | 2019 | ||
2099 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { | 2020 | if (use_fh_prio && (info->flags & INFO_FL_PRIO)) { |
2100 | if (ret < 0) { | 2021 | ret = v4l2_prio_check(vfd->prio, vfh->prio); |
2101 | v4l_print_ioctl(vfd->name, cmd); | 2022 | if (ret) |
2102 | printk(KERN_CONT " error %ld\n", ret); | 2023 | goto done; |
2024 | } | ||
2025 | } else { | ||
2026 | default_info.ioctl = cmd; | ||
2027 | default_info.flags = 0; | ||
2028 | default_info.debug = v4l_print_default; | ||
2029 | info = &default_info; | ||
2030 | } | ||
2031 | |||
2032 | write_only = _IOC_DIR(cmd) == _IOC_WRITE; | ||
2033 | if (write_only && debug > V4L2_DEBUG_IOCTL) { | ||
2034 | v4l_printk_ioctl(video_device_node_name(vfd), cmd); | ||
2035 | pr_cont(": "); | ||
2036 | info->debug(arg, write_only); | ||
2037 | } | ||
2038 | if (info->flags & INFO_FL_STD) { | ||
2039 | typedef int (*vidioc_op)(struct file *file, void *fh, void *p); | ||
2040 | const void *p = vfd->ioctl_ops; | ||
2041 | const vidioc_op *vidioc = p + info->offset; | ||
2042 | |||
2043 | ret = (*vidioc)(file, fh, arg); | ||
2044 | } else if (info->flags & INFO_FL_FUNC) { | ||
2045 | ret = info->func(ops, file, fh, arg); | ||
2046 | } else if (!ops->vidioc_default) { | ||
2047 | ret = -ENOTTY; | ||
2048 | } else { | ||
2049 | ret = ops->vidioc_default(file, fh, | ||
2050 | use_fh_prio ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0, | ||
2051 | cmd, arg); | ||
2052 | } | ||
2053 | |||
2054 | done: | ||
2055 | if (debug) { | ||
2056 | if (write_only && debug > V4L2_DEBUG_IOCTL) { | ||
2057 | if (ret < 0) | ||
2058 | printk(KERN_DEBUG "%s: error %ld\n", | ||
2059 | video_device_node_name(vfd), ret); | ||
2060 | return ret; | ||
2061 | } | ||
2062 | v4l_printk_ioctl(video_device_node_name(vfd), cmd); | ||
2063 | if (ret < 0) | ||
2064 | pr_cont(": error %ld\n", ret); | ||
2065 | else if (debug == V4L2_DEBUG_IOCTL) | ||
2066 | pr_cont("\n"); | ||
2067 | else if (_IOC_DIR(cmd) == _IOC_NONE) | ||
2068 | info->debug(arg, write_only); | ||
2069 | else { | ||
2070 | pr_cont(": "); | ||
2071 | info->debug(arg, write_only); | ||
2103 | } | 2072 | } |
2104 | } | 2073 | } |
2105 | 2074 | ||
2106 | return ret; | 2075 | return ret; |
2107 | } | 2076 | } |
2108 | 2077 | ||
2109 | /* In some cases, only a few fields are used as input, i.e. when the app sets | ||
2110 | * "index" and then the driver fills in the rest of the structure for the thing | ||
2111 | * with that index. We only need to copy up the first non-input field. */ | ||
2112 | static unsigned long cmd_input_size(unsigned int cmd) | ||
2113 | { | ||
2114 | /* Size of structure up to and including 'field' */ | ||
2115 | #define CMDINSIZE(cmd, type, field) \ | ||
2116 | case VIDIOC_##cmd: \ | ||
2117 | return offsetof(struct v4l2_##type, field) + \ | ||
2118 | sizeof(((struct v4l2_##type *)0)->field); | ||
2119 | |||
2120 | switch (cmd) { | ||
2121 | CMDINSIZE(ENUM_FMT, fmtdesc, type); | ||
2122 | CMDINSIZE(G_FMT, format, type); | ||
2123 | CMDINSIZE(QUERYBUF, buffer, length); | ||
2124 | CMDINSIZE(G_PARM, streamparm, type); | ||
2125 | CMDINSIZE(ENUMSTD, standard, index); | ||
2126 | CMDINSIZE(ENUMINPUT, input, index); | ||
2127 | CMDINSIZE(G_CTRL, control, id); | ||
2128 | CMDINSIZE(G_TUNER, tuner, index); | ||
2129 | CMDINSIZE(QUERYCTRL, queryctrl, id); | ||
2130 | CMDINSIZE(QUERYMENU, querymenu, index); | ||
2131 | CMDINSIZE(ENUMOUTPUT, output, index); | ||
2132 | CMDINSIZE(G_MODULATOR, modulator, index); | ||
2133 | CMDINSIZE(G_FREQUENCY, frequency, tuner); | ||
2134 | CMDINSIZE(CROPCAP, cropcap, type); | ||
2135 | CMDINSIZE(G_CROP, crop, type); | ||
2136 | CMDINSIZE(ENUMAUDIO, audio, index); | ||
2137 | CMDINSIZE(ENUMAUDOUT, audioout, index); | ||
2138 | CMDINSIZE(ENCODER_CMD, encoder_cmd, flags); | ||
2139 | CMDINSIZE(TRY_ENCODER_CMD, encoder_cmd, flags); | ||
2140 | CMDINSIZE(G_SLICED_VBI_CAP, sliced_vbi_cap, type); | ||
2141 | CMDINSIZE(ENUM_FRAMESIZES, frmsizeenum, pixel_format); | ||
2142 | CMDINSIZE(ENUM_FRAMEINTERVALS, frmivalenum, height); | ||
2143 | default: | ||
2144 | return _IOC_SIZE(cmd); | ||
2145 | } | ||
2146 | } | ||
2147 | |||
2148 | static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, | 2078 | static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, |
2149 | void * __user *user_ptr, void ***kernel_ptr) | 2079 | void * __user *user_ptr, void ***kernel_ptr) |
2150 | { | 2080 | { |
@@ -2219,7 +2149,20 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, | |||
2219 | 2149 | ||
2220 | err = -EFAULT; | 2150 | err = -EFAULT; |
2221 | if (_IOC_DIR(cmd) & _IOC_WRITE) { | 2151 | if (_IOC_DIR(cmd) & _IOC_WRITE) { |
2222 | unsigned long n = cmd_input_size(cmd); | 2152 | unsigned int n = _IOC_SIZE(cmd); |
2153 | |||
2154 | /* | ||
2155 | * In some cases, only a few fields are used as input, | ||
2156 | * i.e. when the app sets "index" and then the driver | ||
2157 | * fills in the rest of the structure for the thing | ||
2158 | * with that index. We only need to copy up the first | ||
2159 | * non-input field. | ||
2160 | */ | ||
2161 | if (v4l2_is_known_ioctl(cmd)) { | ||
2162 | u32 flags = v4l2_ioctls[_IOC_NR(cmd)].flags; | ||
2163 | if (flags & INFO_FL_CLEAR_MASK) | ||
2164 | n = (flags & INFO_FL_CLEAR_MASK) >> 16; | ||
2165 | } | ||
2223 | 2166 | ||
2224 | if (copy_from_user(parg, (void __user *)arg, n)) | 2167 | if (copy_from_user(parg, (void __user *)arg, n)) |
2225 | goto out; | 2168 | goto out; |
diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c index db6e859b93d4..9182f81deb5b 100644 --- a/drivers/media/video/v4l2-subdev.c +++ b/drivers/media/video/v4l2-subdev.c | |||
@@ -245,7 +245,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
245 | memset(&sel, 0, sizeof(sel)); | 245 | memset(&sel, 0, sizeof(sel)); |
246 | sel.which = crop->which; | 246 | sel.which = crop->which; |
247 | sel.pad = crop->pad; | 247 | sel.pad = crop->pad; |
248 | sel.target = V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL; | 248 | sel.target = V4L2_SEL_TGT_CROP; |
249 | 249 | ||
250 | rval = v4l2_subdev_call( | 250 | rval = v4l2_subdev_call( |
251 | sd, pad, get_selection, subdev_fh, &sel); | 251 | sd, pad, get_selection, subdev_fh, &sel); |
@@ -274,7 +274,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg) | |||
274 | memset(&sel, 0, sizeof(sel)); | 274 | memset(&sel, 0, sizeof(sel)); |
275 | sel.which = crop->which; | 275 | sel.which = crop->which; |
276 | sel.pad = crop->pad; | 276 | sel.pad = crop->pad; |
277 | sel.target = V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL; | 277 | sel.target = V4L2_SEL_TGT_CROP; |
278 | sel.r = crop->rect; | 278 | sel.r = crop->rect; |
279 | 279 | ||
280 | rval = v4l2_subdev_call( | 280 | rval = v4l2_subdev_call( |
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index ffdf59cfe405..bf7a326b1cdc 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c | |||
@@ -359,11 +359,6 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b, | |||
359 | break; | 359 | break; |
360 | } | 360 | } |
361 | 361 | ||
362 | if (vb->input != UNSET) { | ||
363 | b->flags |= V4L2_BUF_FLAG_INPUT; | ||
364 | b->input = vb->input; | ||
365 | } | ||
366 | |||
367 | b->field = vb->field; | 362 | b->field = vb->field; |
368 | b->timestamp = vb->ts; | 363 | b->timestamp = vb->ts; |
369 | b->bytesused = vb->size; | 364 | b->bytesused = vb->size; |
@@ -402,7 +397,6 @@ int __videobuf_mmap_setup(struct videobuf_queue *q, | |||
402 | break; | 397 | break; |
403 | 398 | ||
404 | q->bufs[i]->i = i; | 399 | q->bufs[i]->i = i; |
405 | q->bufs[i]->input = UNSET; | ||
406 | q->bufs[i]->memory = memory; | 400 | q->bufs[i]->memory = memory; |
407 | q->bufs[i]->bsize = bsize; | 401 | q->bufs[i]->bsize = bsize; |
408 | switch (memory) { | 402 | switch (memory) { |
@@ -566,16 +560,6 @@ int videobuf_qbuf(struct videobuf_queue *q, struct v4l2_buffer *b) | |||
566 | goto done; | 560 | goto done; |
567 | } | 561 | } |
568 | 562 | ||
569 | if (b->flags & V4L2_BUF_FLAG_INPUT) { | ||
570 | if (b->input >= q->inputs) { | ||
571 | dprintk(1, "qbuf: wrong input.\n"); | ||
572 | goto done; | ||
573 | } | ||
574 | buf->input = b->input; | ||
575 | } else { | ||
576 | buf->input = UNSET; | ||
577 | } | ||
578 | |||
579 | switch (b->memory) { | 563 | switch (b->memory) { |
580 | case V4L2_MEMORY_MMAP: | 564 | case V4L2_MEMORY_MMAP: |
581 | if (0 == buf->baddr) { | 565 | if (0 == buf->baddr) { |
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c index b6b5cc1a43cb..9b9a06fdd0f0 100644 --- a/drivers/media/video/videobuf-dma-contig.c +++ b/drivers/media/video/videobuf-dma-contig.c | |||
@@ -40,7 +40,7 @@ struct videobuf_dma_contig_memory { | |||
40 | 40 | ||
41 | static int __videobuf_dc_alloc(struct device *dev, | 41 | static int __videobuf_dc_alloc(struct device *dev, |
42 | struct videobuf_dma_contig_memory *mem, | 42 | struct videobuf_dma_contig_memory *mem, |
43 | unsigned long size, unsigned long flags) | 43 | unsigned long size, gfp_t flags) |
44 | { | 44 | { |
45 | mem->size = size; | 45 | mem->size = size; |
46 | if (mem->cached) { | 46 | if (mem->cached) { |
diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 9d4e9edbd2e7..4e0290ab5071 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c | |||
@@ -336,9 +336,9 @@ static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) | |||
336 | struct vb2_queue *q = vb->vb2_queue; | 336 | struct vb2_queue *q = vb->vb2_queue; |
337 | int ret; | 337 | int ret; |
338 | 338 | ||
339 | /* Copy back data such as timestamp, flags, input, etc. */ | 339 | /* Copy back data such as timestamp, flags, etc. */ |
340 | memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); | 340 | memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); |
341 | b->input = vb->v4l2_buf.input; | 341 | b->reserved2 = vb->v4l2_buf.reserved2; |
342 | b->reserved = vb->v4l2_buf.reserved; | 342 | b->reserved = vb->v4l2_buf.reserved; |
343 | 343 | ||
344 | if (V4L2_TYPE_IS_MULTIPLANAR(q->type)) { | 344 | if (V4L2_TYPE_IS_MULTIPLANAR(q->type)) { |
@@ -454,7 +454,50 @@ static int __verify_mmap_ops(struct vb2_queue *q) | |||
454 | } | 454 | } |
455 | 455 | ||
456 | /** | 456 | /** |
457 | * vb2_reqbufs() - Initiate streaming | 457 | * __verify_memory_type() - Check whether the memory type and buffer type |
458 | * passed to a buffer operation are compatible with the queue. | ||
459 | */ | ||
460 | static int __verify_memory_type(struct vb2_queue *q, | ||
461 | enum v4l2_memory memory, enum v4l2_buf_type type) | ||
462 | { | ||
463 | if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR) { | ||
464 | dprintk(1, "reqbufs: unsupported memory type\n"); | ||
465 | return -EINVAL; | ||
466 | } | ||
467 | |||
468 | if (type != q->type) { | ||
469 | dprintk(1, "reqbufs: requested type is incorrect\n"); | ||
470 | return -EINVAL; | ||
471 | } | ||
472 | |||
473 | /* | ||
474 | * Make sure all the required memory ops for given memory type | ||
475 | * are available. | ||
476 | */ | ||
477 | if (memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { | ||
478 | dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); | ||
479 | return -EINVAL; | ||
480 | } | ||
481 | |||
482 | if (memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { | ||
483 | dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); | ||
484 | return -EINVAL; | ||
485 | } | ||
486 | |||
487 | /* | ||
488 | * Place the busy tests at the end: -EBUSY can be ignored when | ||
489 | * create_bufs is called with count == 0, but count == 0 should still | ||
490 | * do the memory and type validation. | ||
491 | */ | ||
492 | if (q->fileio) { | ||
493 | dprintk(1, "reqbufs: file io in progress\n"); | ||
494 | return -EBUSY; | ||
495 | } | ||
496 | return 0; | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * __reqbufs() - Initiate streaming | ||
458 | * @q: videobuf2 queue | 501 | * @q: videobuf2 queue |
459 | * @req: struct passed from userspace to vidioc_reqbufs handler in driver | 502 | * @req: struct passed from userspace to vidioc_reqbufs handler in driver |
460 | * | 503 | * |
@@ -476,46 +519,16 @@ static int __verify_mmap_ops(struct vb2_queue *q) | |||
476 | * The return values from this function are intended to be directly returned | 519 | * The return values from this function are intended to be directly returned |
477 | * from vidioc_reqbufs handler in driver. | 520 | * from vidioc_reqbufs handler in driver. |
478 | */ | 521 | */ |
479 | int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) | 522 | static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) |
480 | { | 523 | { |
481 | unsigned int num_buffers, allocated_buffers, num_planes = 0; | 524 | unsigned int num_buffers, allocated_buffers, num_planes = 0; |
482 | int ret = 0; | 525 | int ret; |
483 | |||
484 | if (q->fileio) { | ||
485 | dprintk(1, "reqbufs: file io in progress\n"); | ||
486 | return -EBUSY; | ||
487 | } | ||
488 | |||
489 | if (req->memory != V4L2_MEMORY_MMAP | ||
490 | && req->memory != V4L2_MEMORY_USERPTR) { | ||
491 | dprintk(1, "reqbufs: unsupported memory type\n"); | ||
492 | return -EINVAL; | ||
493 | } | ||
494 | |||
495 | if (req->type != q->type) { | ||
496 | dprintk(1, "reqbufs: requested type is incorrect\n"); | ||
497 | return -EINVAL; | ||
498 | } | ||
499 | 526 | ||
500 | if (q->streaming) { | 527 | if (q->streaming) { |
501 | dprintk(1, "reqbufs: streaming active\n"); | 528 | dprintk(1, "reqbufs: streaming active\n"); |
502 | return -EBUSY; | 529 | return -EBUSY; |
503 | } | 530 | } |
504 | 531 | ||
505 | /* | ||
506 | * Make sure all the required memory ops for given memory type | ||
507 | * are available. | ||
508 | */ | ||
509 | if (req->memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { | ||
510 | dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); | ||
511 | return -EINVAL; | ||
512 | } | ||
513 | |||
514 | if (req->memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { | ||
515 | dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); | ||
516 | return -EINVAL; | ||
517 | } | ||
518 | |||
519 | if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) { | 532 | if (req->count == 0 || q->num_buffers != 0 || q->memory != req->memory) { |
520 | /* | 533 | /* |
521 | * We already have buffers allocated, so first check if they | 534 | * We already have buffers allocated, so first check if they |
@@ -595,10 +608,23 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) | |||
595 | 608 | ||
596 | return 0; | 609 | return 0; |
597 | } | 610 | } |
611 | |||
612 | /** | ||
613 | * vb2_reqbufs() - Wrapper for __reqbufs() that also verifies the memory and | ||
614 | * type values. | ||
615 | * @q: videobuf2 queue | ||
616 | * @req: struct passed from userspace to vidioc_reqbufs handler in driver | ||
617 | */ | ||
618 | int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) | ||
619 | { | ||
620 | int ret = __verify_memory_type(q, req->memory, req->type); | ||
621 | |||
622 | return ret ? ret : __reqbufs(q, req); | ||
623 | } | ||
598 | EXPORT_SYMBOL_GPL(vb2_reqbufs); | 624 | EXPORT_SYMBOL_GPL(vb2_reqbufs); |
599 | 625 | ||
600 | /** | 626 | /** |
601 | * vb2_create_bufs() - Allocate buffers and any required auxiliary structs | 627 | * __create_bufs() - Allocate buffers and any required auxiliary structs |
602 | * @q: videobuf2 queue | 628 | * @q: videobuf2 queue |
603 | * @create: creation parameters, passed from userspace to vidioc_create_bufs | 629 | * @create: creation parameters, passed from userspace to vidioc_create_bufs |
604 | * handler in driver | 630 | * handler in driver |
@@ -612,40 +638,10 @@ EXPORT_SYMBOL_GPL(vb2_reqbufs); | |||
612 | * The return values from this function are intended to be directly returned | 638 | * The return values from this function are intended to be directly returned |
613 | * from vidioc_create_bufs handler in driver. | 639 | * from vidioc_create_bufs handler in driver. |
614 | */ | 640 | */ |
615 | int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) | 641 | static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) |
616 | { | 642 | { |
617 | unsigned int num_planes = 0, num_buffers, allocated_buffers; | 643 | unsigned int num_planes = 0, num_buffers, allocated_buffers; |
618 | int ret = 0; | 644 | int ret; |
619 | |||
620 | if (q->fileio) { | ||
621 | dprintk(1, "%s(): file io in progress\n", __func__); | ||
622 | return -EBUSY; | ||
623 | } | ||
624 | |||
625 | if (create->memory != V4L2_MEMORY_MMAP | ||
626 | && create->memory != V4L2_MEMORY_USERPTR) { | ||
627 | dprintk(1, "%s(): unsupported memory type\n", __func__); | ||
628 | return -EINVAL; | ||
629 | } | ||
630 | |||
631 | if (create->format.type != q->type) { | ||
632 | dprintk(1, "%s(): requested type is incorrect\n", __func__); | ||
633 | return -EINVAL; | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * Make sure all the required memory ops for given memory type | ||
638 | * are available. | ||
639 | */ | ||
640 | if (create->memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { | ||
641 | dprintk(1, "%s(): MMAP for current setup unsupported\n", __func__); | ||
642 | return -EINVAL; | ||
643 | } | ||
644 | |||
645 | if (create->memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { | ||
646 | dprintk(1, "%s(): USERPTR for current setup unsupported\n", __func__); | ||
647 | return -EINVAL; | ||
648 | } | ||
649 | 645 | ||
650 | if (q->num_buffers == VIDEO_MAX_FRAME) { | 646 | if (q->num_buffers == VIDEO_MAX_FRAME) { |
651 | dprintk(1, "%s(): maximum number of buffers already allocated\n", | 647 | dprintk(1, "%s(): maximum number of buffers already allocated\n", |
@@ -653,8 +649,6 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) | |||
653 | return -ENOBUFS; | 649 | return -ENOBUFS; |
654 | } | 650 | } |
655 | 651 | ||
656 | create->index = q->num_buffers; | ||
657 | |||
658 | if (!q->num_buffers) { | 652 | if (!q->num_buffers) { |
659 | memset(q->plane_sizes, 0, sizeof(q->plane_sizes)); | 653 | memset(q->plane_sizes, 0, sizeof(q->plane_sizes)); |
660 | memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); | 654 | memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); |
@@ -675,9 +669,9 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) | |||
675 | /* Finally, allocate buffers and video memory */ | 669 | /* Finally, allocate buffers and video memory */ |
676 | ret = __vb2_queue_alloc(q, create->memory, num_buffers, | 670 | ret = __vb2_queue_alloc(q, create->memory, num_buffers, |
677 | num_planes); | 671 | num_planes); |
678 | if (ret < 0) { | 672 | if (ret == 0) { |
679 | dprintk(1, "Memory allocation failed with error: %d\n", ret); | 673 | dprintk(1, "Memory allocation failed\n"); |
680 | return ret; | 674 | return -ENOMEM; |
681 | } | 675 | } |
682 | 676 | ||
683 | allocated_buffers = ret; | 677 | allocated_buffers = ret; |
@@ -708,7 +702,7 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) | |||
708 | 702 | ||
709 | if (ret < 0) { | 703 | if (ret < 0) { |
710 | __vb2_queue_free(q, allocated_buffers); | 704 | __vb2_queue_free(q, allocated_buffers); |
711 | return ret; | 705 | return -ENOMEM; |
712 | } | 706 | } |
713 | 707 | ||
714 | /* | 708 | /* |
@@ -719,6 +713,23 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) | |||
719 | 713 | ||
720 | return 0; | 714 | return 0; |
721 | } | 715 | } |
716 | |||
717 | /** | ||
718 | * vb2_reqbufs() - Wrapper for __reqbufs() that also verifies the memory and | ||
719 | * type values. | ||
720 | * @q: videobuf2 queue | ||
721 | * @create: creation parameters, passed from userspace to vidioc_create_bufs | ||
722 | * handler in driver | ||
723 | */ | ||
724 | int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) | ||
725 | { | ||
726 | int ret = __verify_memory_type(q, create->memory, create->format.type); | ||
727 | |||
728 | create->index = q->num_buffers; | ||
729 | if (create->count == 0) | ||
730 | return ret != -EBUSY ? ret : 0; | ||
731 | return ret ? ret : __create_bufs(q, create); | ||
732 | } | ||
722 | EXPORT_SYMBOL_GPL(vb2_create_bufs); | 733 | EXPORT_SYMBOL_GPL(vb2_create_bufs); |
723 | 734 | ||
724 | /** | 735 | /** |
@@ -860,7 +871,6 @@ static int __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b, | |||
860 | 871 | ||
861 | vb->v4l2_buf.field = b->field; | 872 | vb->v4l2_buf.field = b->field; |
862 | vb->v4l2_buf.timestamp = b->timestamp; | 873 | vb->v4l2_buf.timestamp = b->timestamp; |
863 | vb->v4l2_buf.input = b->input; | ||
864 | vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS; | 874 | vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS; |
865 | 875 | ||
866 | return 0; | 876 | return 0; |
@@ -2115,6 +2125,263 @@ size_t vb2_write(struct vb2_queue *q, char __user *data, size_t count, | |||
2115 | } | 2125 | } |
2116 | EXPORT_SYMBOL_GPL(vb2_write); | 2126 | EXPORT_SYMBOL_GPL(vb2_write); |
2117 | 2127 | ||
2128 | |||
2129 | /* | ||
2130 | * The following functions are not part of the vb2 core API, but are helper | ||
2131 | * functions that plug into struct v4l2_ioctl_ops, struct v4l2_file_operations | ||
2132 | * and struct vb2_ops. | ||
2133 | * They contain boilerplate code that most if not all drivers have to do | ||
2134 | * and so they simplify the driver code. | ||
2135 | */ | ||
2136 | |||
2137 | /* The queue is busy if there is a owner and you are not that owner. */ | ||
2138 | static inline bool vb2_queue_is_busy(struct video_device *vdev, struct file *file) | ||
2139 | { | ||
2140 | return vdev->queue->owner && vdev->queue->owner != file->private_data; | ||
2141 | } | ||
2142 | |||
2143 | /* vb2 ioctl helpers */ | ||
2144 | |||
2145 | int vb2_ioctl_reqbufs(struct file *file, void *priv, | ||
2146 | struct v4l2_requestbuffers *p) | ||
2147 | { | ||
2148 | struct video_device *vdev = video_devdata(file); | ||
2149 | int res = __verify_memory_type(vdev->queue, p->memory, p->type); | ||
2150 | |||
2151 | if (res) | ||
2152 | return res; | ||
2153 | if (vb2_queue_is_busy(vdev, file)) | ||
2154 | return -EBUSY; | ||
2155 | res = __reqbufs(vdev->queue, p); | ||
2156 | /* If count == 0, then the owner has released all buffers and he | ||
2157 | is no longer owner of the queue. Otherwise we have a new owner. */ | ||
2158 | if (res == 0) | ||
2159 | vdev->queue->owner = p->count ? file->private_data : NULL; | ||
2160 | return res; | ||
2161 | } | ||
2162 | EXPORT_SYMBOL_GPL(vb2_ioctl_reqbufs); | ||
2163 | |||
2164 | int vb2_ioctl_create_bufs(struct file *file, void *priv, | ||
2165 | struct v4l2_create_buffers *p) | ||
2166 | { | ||
2167 | struct video_device *vdev = video_devdata(file); | ||
2168 | int res = __verify_memory_type(vdev->queue, p->memory, p->format.type); | ||
2169 | |||
2170 | p->index = vdev->queue->num_buffers; | ||
2171 | /* If count == 0, then just check if memory and type are valid. | ||
2172 | Any -EBUSY result from __verify_memory_type can be mapped to 0. */ | ||
2173 | if (p->count == 0) | ||
2174 | return res != -EBUSY ? res : 0; | ||
2175 | if (res) | ||
2176 | return res; | ||
2177 | if (vb2_queue_is_busy(vdev, file)) | ||
2178 | return -EBUSY; | ||
2179 | res = __create_bufs(vdev->queue, p); | ||
2180 | if (res == 0) | ||
2181 | vdev->queue->owner = file->private_data; | ||
2182 | return res; | ||
2183 | } | ||
2184 | EXPORT_SYMBOL_GPL(vb2_ioctl_create_bufs); | ||
2185 | |||
2186 | int vb2_ioctl_prepare_buf(struct file *file, void *priv, | ||
2187 | struct v4l2_buffer *p) | ||
2188 | { | ||
2189 | struct video_device *vdev = video_devdata(file); | ||
2190 | |||
2191 | if (vb2_queue_is_busy(vdev, file)) | ||
2192 | return -EBUSY; | ||
2193 | return vb2_prepare_buf(vdev->queue, p); | ||
2194 | } | ||
2195 | EXPORT_SYMBOL_GPL(vb2_ioctl_prepare_buf); | ||
2196 | |||
2197 | int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
2198 | { | ||
2199 | struct video_device *vdev = video_devdata(file); | ||
2200 | |||
2201 | /* No need to call vb2_queue_is_busy(), anyone can query buffers. */ | ||
2202 | return vb2_querybuf(vdev->queue, p); | ||
2203 | } | ||
2204 | EXPORT_SYMBOL_GPL(vb2_ioctl_querybuf); | ||
2205 | |||
2206 | int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
2207 | { | ||
2208 | struct video_device *vdev = video_devdata(file); | ||
2209 | |||
2210 | if (vb2_queue_is_busy(vdev, file)) | ||
2211 | return -EBUSY; | ||
2212 | return vb2_qbuf(vdev->queue, p); | ||
2213 | } | ||
2214 | EXPORT_SYMBOL_GPL(vb2_ioctl_qbuf); | ||
2215 | |||
2216 | int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
2217 | { | ||
2218 | struct video_device *vdev = video_devdata(file); | ||
2219 | |||
2220 | if (vb2_queue_is_busy(vdev, file)) | ||
2221 | return -EBUSY; | ||
2222 | return vb2_dqbuf(vdev->queue, p, file->f_flags & O_NONBLOCK); | ||
2223 | } | ||
2224 | EXPORT_SYMBOL_GPL(vb2_ioctl_dqbuf); | ||
2225 | |||
2226 | int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | ||
2227 | { | ||
2228 | struct video_device *vdev = video_devdata(file); | ||
2229 | |||
2230 | if (vb2_queue_is_busy(vdev, file)) | ||
2231 | return -EBUSY; | ||
2232 | return vb2_streamon(vdev->queue, i); | ||
2233 | } | ||
2234 | EXPORT_SYMBOL_GPL(vb2_ioctl_streamon); | ||
2235 | |||
2236 | int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | ||
2237 | { | ||
2238 | struct video_device *vdev = video_devdata(file); | ||
2239 | |||
2240 | if (vb2_queue_is_busy(vdev, file)) | ||
2241 | return -EBUSY; | ||
2242 | return vb2_streamoff(vdev->queue, i); | ||
2243 | } | ||
2244 | EXPORT_SYMBOL_GPL(vb2_ioctl_streamoff); | ||
2245 | |||
2246 | /* v4l2_file_operations helpers */ | ||
2247 | |||
2248 | int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma) | ||
2249 | { | ||
2250 | struct video_device *vdev = video_devdata(file); | ||
2251 | |||
2252 | return vb2_mmap(vdev->queue, vma); | ||
2253 | } | ||
2254 | EXPORT_SYMBOL_GPL(vb2_fop_mmap); | ||
2255 | |||
2256 | int vb2_fop_release(struct file *file) | ||
2257 | { | ||
2258 | struct video_device *vdev = video_devdata(file); | ||
2259 | |||
2260 | if (file->private_data == vdev->queue->owner) { | ||
2261 | vb2_queue_release(vdev->queue); | ||
2262 | vdev->queue->owner = NULL; | ||
2263 | } | ||
2264 | return v4l2_fh_release(file); | ||
2265 | } | ||
2266 | EXPORT_SYMBOL_GPL(vb2_fop_release); | ||
2267 | |||
2268 | ssize_t vb2_fop_write(struct file *file, char __user *buf, | ||
2269 | size_t count, loff_t *ppos) | ||
2270 | { | ||
2271 | struct video_device *vdev = video_devdata(file); | ||
2272 | struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; | ||
2273 | bool must_lock = !test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) && lock; | ||
2274 | int err = -EBUSY; | ||
2275 | |||
2276 | if (must_lock && mutex_lock_interruptible(lock)) | ||
2277 | return -ERESTARTSYS; | ||
2278 | if (vb2_queue_is_busy(vdev, file)) | ||
2279 | goto exit; | ||
2280 | err = vb2_write(vdev->queue, buf, count, ppos, | ||
2281 | file->f_flags & O_NONBLOCK); | ||
2282 | if (err >= 0) | ||
2283 | vdev->queue->owner = file->private_data; | ||
2284 | exit: | ||
2285 | if (must_lock) | ||
2286 | mutex_unlock(lock); | ||
2287 | return err; | ||
2288 | } | ||
2289 | EXPORT_SYMBOL_GPL(vb2_fop_write); | ||
2290 | |||
2291 | ssize_t vb2_fop_read(struct file *file, char __user *buf, | ||
2292 | size_t count, loff_t *ppos) | ||
2293 | { | ||
2294 | struct video_device *vdev = video_devdata(file); | ||
2295 | struct mutex *lock = vdev->queue->lock ? vdev->queue->lock : vdev->lock; | ||
2296 | bool must_lock = !test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags) && vdev->lock; | ||
2297 | int err = -EBUSY; | ||
2298 | |||
2299 | if (must_lock && mutex_lock_interruptible(lock)) | ||
2300 | return -ERESTARTSYS; | ||
2301 | if (vb2_queue_is_busy(vdev, file)) | ||
2302 | goto exit; | ||
2303 | err = vb2_read(vdev->queue, buf, count, ppos, | ||
2304 | file->f_flags & O_NONBLOCK); | ||
2305 | if (err >= 0) | ||
2306 | vdev->queue->owner = file->private_data; | ||
2307 | exit: | ||
2308 | if (must_lock) | ||
2309 | mutex_unlock(lock); | ||
2310 | return err; | ||
2311 | } | ||
2312 | EXPORT_SYMBOL_GPL(vb2_fop_read); | ||
2313 | |||
2314 | unsigned int vb2_fop_poll(struct file *file, poll_table *wait) | ||
2315 | { | ||
2316 | struct video_device *vdev = video_devdata(file); | ||
2317 | struct vb2_queue *q = vdev->queue; | ||
2318 | struct mutex *lock = q->lock ? q->lock : vdev->lock; | ||
2319 | unsigned long req_events = poll_requested_events(wait); | ||
2320 | unsigned res; | ||
2321 | void *fileio; | ||
2322 | /* Yuck. We really need to get rid of this flag asap. If it is | ||
2323 | set, then the core took the serialization lock before calling | ||
2324 | poll(). This is being phased out, but for now we have to handle | ||
2325 | this case. */ | ||
2326 | bool locked = test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags); | ||
2327 | bool must_lock = false; | ||
2328 | |||
2329 | /* Try to be smart: only lock if polling might start fileio, | ||
2330 | otherwise locking will only introduce unwanted delays. */ | ||
2331 | if (q->num_buffers == 0 && q->fileio == NULL) { | ||
2332 | if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) && | ||
2333 | (req_events & (POLLIN | POLLRDNORM))) | ||
2334 | must_lock = true; | ||
2335 | else if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE) && | ||
2336 | (req_events & (POLLOUT | POLLWRNORM))) | ||
2337 | must_lock = true; | ||
2338 | } | ||
2339 | |||
2340 | /* If locking is needed, but this helper doesn't know how, then you | ||
2341 | shouldn't be using this helper but you should write your own. */ | ||
2342 | WARN_ON(must_lock && !locked && !lock); | ||
2343 | |||
2344 | if (must_lock && !locked && lock && mutex_lock_interruptible(lock)) | ||
2345 | return POLLERR; | ||
2346 | |||
2347 | fileio = q->fileio; | ||
2348 | |||
2349 | res = vb2_poll(vdev->queue, file, wait); | ||
2350 | |||
2351 | /* If fileio was started, then we have a new queue owner. */ | ||
2352 | if (must_lock && !fileio && q->fileio) | ||
2353 | q->owner = file->private_data; | ||
2354 | if (must_lock && !locked && lock) | ||
2355 | mutex_unlock(lock); | ||
2356 | return res; | ||
2357 | } | ||
2358 | EXPORT_SYMBOL_GPL(vb2_fop_poll); | ||
2359 | |||
2360 | #ifndef CONFIG_MMU | ||
2361 | unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr, | ||
2362 | unsigned long len, unsigned long pgoff, unsigned long flags) | ||
2363 | { | ||
2364 | struct video_device *vdev = video_devdata(file); | ||
2365 | |||
2366 | return vb2_get_unmapped_area(vdev->queue, addr, len, pgoff, flags); | ||
2367 | } | ||
2368 | EXPORT_SYMBOL_GPL(vb2_fop_get_unmapped_area); | ||
2369 | #endif | ||
2370 | |||
2371 | /* vb2_ops helpers. Only use if vq->lock is non-NULL. */ | ||
2372 | |||
2373 | void vb2_ops_wait_prepare(struct vb2_queue *vq) | ||
2374 | { | ||
2375 | mutex_unlock(vq->lock); | ||
2376 | } | ||
2377 | EXPORT_SYMBOL_GPL(vb2_ops_wait_prepare); | ||
2378 | |||
2379 | void vb2_ops_wait_finish(struct vb2_queue *vq) | ||
2380 | { | ||
2381 | mutex_lock(vq->lock); | ||
2382 | } | ||
2383 | EXPORT_SYMBOL_GPL(vb2_ops_wait_finish); | ||
2384 | |||
2118 | MODULE_DESCRIPTION("Driver helper framework for Video for Linux 2"); | 2385 | MODULE_DESCRIPTION("Driver helper framework for Video for Linux 2"); |
2119 | MODULE_AUTHOR("Pawel Osciak <pawel@osciak.com>, Marek Szyprowski"); | 2386 | MODULE_AUTHOR("Pawel Osciak <pawel@osciak.com>, Marek Szyprowski"); |
2120 | MODULE_LICENSE("GPL"); | 2387 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 08c10240e70f..1e8c4f3ab602 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -188,6 +188,7 @@ struct vivi_dev { | |||
188 | struct list_head vivi_devlist; | 188 | struct list_head vivi_devlist; |
189 | struct v4l2_device v4l2_dev; | 189 | struct v4l2_device v4l2_dev; |
190 | struct v4l2_ctrl_handler ctrl_handler; | 190 | struct v4l2_ctrl_handler ctrl_handler; |
191 | struct video_device vdev; | ||
191 | 192 | ||
192 | /* controls */ | 193 | /* controls */ |
193 | struct v4l2_ctrl *brightness; | 194 | struct v4l2_ctrl *brightness; |
@@ -213,9 +214,6 @@ struct vivi_dev { | |||
213 | spinlock_t slock; | 214 | spinlock_t slock; |
214 | struct mutex mutex; | 215 | struct mutex mutex; |
215 | 216 | ||
216 | /* various device info */ | ||
217 | struct video_device *vfd; | ||
218 | |||
219 | struct vivi_dmaqueue vidq; | 217 | struct vivi_dmaqueue vidq; |
220 | 218 | ||
221 | /* Several counters */ | 219 | /* Several counters */ |
@@ -769,7 +767,13 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
769 | struct vivi_dev *dev = vb2_get_drv_priv(vq); | 767 | struct vivi_dev *dev = vb2_get_drv_priv(vq); |
770 | unsigned long size; | 768 | unsigned long size; |
771 | 769 | ||
772 | size = dev->width * dev->height * dev->pixelsize; | 770 | if (fmt) |
771 | size = fmt->fmt.pix.sizeimage; | ||
772 | else | ||
773 | size = dev->width * dev->height * dev->pixelsize; | ||
774 | |||
775 | if (size == 0) | ||
776 | return -EINVAL; | ||
773 | 777 | ||
774 | if (0 == *nbuffers) | 778 | if (0 == *nbuffers) |
775 | *nbuffers = 32; | 779 | *nbuffers = 32; |
@@ -792,27 +796,6 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
792 | return 0; | 796 | return 0; |
793 | } | 797 | } |
794 | 798 | ||
795 | static int buffer_init(struct vb2_buffer *vb) | ||
796 | { | ||
797 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | ||
798 | |||
799 | BUG_ON(NULL == dev->fmt); | ||
800 | |||
801 | /* | ||
802 | * This callback is called once per buffer, after its allocation. | ||
803 | * | ||
804 | * Vivi does not allow changing format during streaming, but it is | ||
805 | * possible to do so when streaming is paused (i.e. in streamoff state). | ||
806 | * Buffers however are not freed when going into streamoff and so | ||
807 | * buffer size verification has to be done in buffer_prepare, on each | ||
808 | * qbuf. | ||
809 | * It would be best to move verification code here to buf_init and | ||
810 | * s_fmt though. | ||
811 | */ | ||
812 | |||
813 | return 0; | ||
814 | } | ||
815 | |||
816 | static int buffer_prepare(struct vb2_buffer *vb) | 799 | static int buffer_prepare(struct vb2_buffer *vb) |
817 | { | 800 | { |
818 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | 801 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); |
@@ -850,20 +833,6 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
850 | return 0; | 833 | return 0; |
851 | } | 834 | } |
852 | 835 | ||
853 | static int buffer_finish(struct vb2_buffer *vb) | ||
854 | { | ||
855 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | ||
856 | dprintk(dev, 1, "%s\n", __func__); | ||
857 | return 0; | ||
858 | } | ||
859 | |||
860 | static void buffer_cleanup(struct vb2_buffer *vb) | ||
861 | { | ||
862 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | ||
863 | dprintk(dev, 1, "%s\n", __func__); | ||
864 | |||
865 | } | ||
866 | |||
867 | static void buffer_queue(struct vb2_buffer *vb) | 836 | static void buffer_queue(struct vb2_buffer *vb) |
868 | { | 837 | { |
869 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | 838 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); |
@@ -909,10 +878,7 @@ static void vivi_unlock(struct vb2_queue *vq) | |||
909 | 878 | ||
910 | static struct vb2_ops vivi_video_qops = { | 879 | static struct vb2_ops vivi_video_qops = { |
911 | .queue_setup = queue_setup, | 880 | .queue_setup = queue_setup, |
912 | .buf_init = buffer_init, | ||
913 | .buf_prepare = buffer_prepare, | 881 | .buf_prepare = buffer_prepare, |
914 | .buf_finish = buffer_finish, | ||
915 | .buf_cleanup = buffer_cleanup, | ||
916 | .buf_queue = buffer_queue, | 882 | .buf_queue = buffer_queue, |
917 | .start_streaming = start_streaming, | 883 | .start_streaming = start_streaming, |
918 | .stop_streaming = stop_streaming, | 884 | .stop_streaming = stop_streaming, |
@@ -1021,7 +987,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1021 | if (ret < 0) | 987 | if (ret < 0) |
1022 | return ret; | 988 | return ret; |
1023 | 989 | ||
1024 | if (vb2_is_streaming(q)) { | 990 | if (vb2_is_busy(q)) { |
1025 | dprintk(dev, 1, "%s device busy\n", __func__); | 991 | dprintk(dev, 1, "%s device busy\n", __func__); |
1026 | return -EBUSY; | 992 | return -EBUSY; |
1027 | } | 993 | } |
@@ -1035,48 +1001,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1035 | return 0; | 1001 | return 0; |
1036 | } | 1002 | } |
1037 | 1003 | ||
1038 | static int vidioc_reqbufs(struct file *file, void *priv, | ||
1039 | struct v4l2_requestbuffers *p) | ||
1040 | { | ||
1041 | struct vivi_dev *dev = video_drvdata(file); | ||
1042 | return vb2_reqbufs(&dev->vb_vidq, p); | ||
1043 | } | ||
1044 | |||
1045 | static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
1046 | { | ||
1047 | struct vivi_dev *dev = video_drvdata(file); | ||
1048 | return vb2_querybuf(&dev->vb_vidq, p); | ||
1049 | } | ||
1050 | |||
1051 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
1052 | { | ||
1053 | struct vivi_dev *dev = video_drvdata(file); | ||
1054 | return vb2_qbuf(&dev->vb_vidq, p); | ||
1055 | } | ||
1056 | |||
1057 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
1058 | { | ||
1059 | struct vivi_dev *dev = video_drvdata(file); | ||
1060 | return vb2_dqbuf(&dev->vb_vidq, p, file->f_flags & O_NONBLOCK); | ||
1061 | } | ||
1062 | |||
1063 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | ||
1064 | { | ||
1065 | struct vivi_dev *dev = video_drvdata(file); | ||
1066 | return vb2_streamon(&dev->vb_vidq, i); | ||
1067 | } | ||
1068 | |||
1069 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | ||
1070 | { | ||
1071 | struct vivi_dev *dev = video_drvdata(file); | ||
1072 | return vb2_streamoff(&dev->vb_vidq, i); | ||
1073 | } | ||
1074 | |||
1075 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *i) | ||
1076 | { | ||
1077 | return 0; | ||
1078 | } | ||
1079 | |||
1080 | /* only one input in this sample driver */ | 1004 | /* only one input in this sample driver */ |
1081 | static int vidioc_enum_input(struct file *file, void *priv, | 1005 | static int vidioc_enum_input(struct file *file, void *priv, |
1082 | struct v4l2_input *inp) | 1006 | struct v4l2_input *inp) |
@@ -1085,7 +1009,6 @@ static int vidioc_enum_input(struct file *file, void *priv, | |||
1085 | return -EINVAL; | 1009 | return -EINVAL; |
1086 | 1010 | ||
1087 | inp->type = V4L2_INPUT_TYPE_CAMERA; | 1011 | inp->type = V4L2_INPUT_TYPE_CAMERA; |
1088 | inp->std = V4L2_STD_525_60; | ||
1089 | sprintf(inp->name, "Camera %u", inp->index); | 1012 | sprintf(inp->name, "Camera %u", inp->index); |
1090 | return 0; | 1013 | return 0; |
1091 | } | 1014 | } |
@@ -1145,58 +1068,6 @@ static int vivi_s_ctrl(struct v4l2_ctrl *ctrl) | |||
1145 | File operations for the device | 1068 | File operations for the device |
1146 | ------------------------------------------------------------------*/ | 1069 | ------------------------------------------------------------------*/ |
1147 | 1070 | ||
1148 | static ssize_t | ||
1149 | vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | ||
1150 | { | ||
1151 | struct vivi_dev *dev = video_drvdata(file); | ||
1152 | int err; | ||
1153 | |||
1154 | dprintk(dev, 1, "read called\n"); | ||
1155 | mutex_lock(&dev->mutex); | ||
1156 | err = vb2_read(&dev->vb_vidq, data, count, ppos, | ||
1157 | file->f_flags & O_NONBLOCK); | ||
1158 | mutex_unlock(&dev->mutex); | ||
1159 | return err; | ||
1160 | } | ||
1161 | |||
1162 | static unsigned int | ||
1163 | vivi_poll(struct file *file, struct poll_table_struct *wait) | ||
1164 | { | ||
1165 | struct vivi_dev *dev = video_drvdata(file); | ||
1166 | struct vb2_queue *q = &dev->vb_vidq; | ||
1167 | |||
1168 | dprintk(dev, 1, "%s\n", __func__); | ||
1169 | return vb2_poll(q, file, wait); | ||
1170 | } | ||
1171 | |||
1172 | static int vivi_close(struct file *file) | ||
1173 | { | ||
1174 | struct video_device *vdev = video_devdata(file); | ||
1175 | struct vivi_dev *dev = video_drvdata(file); | ||
1176 | |||
1177 | dprintk(dev, 1, "close called (dev=%s), file %p\n", | ||
1178 | video_device_node_name(vdev), file); | ||
1179 | |||
1180 | if (v4l2_fh_is_singular_file(file)) | ||
1181 | vb2_queue_release(&dev->vb_vidq); | ||
1182 | return v4l2_fh_release(file); | ||
1183 | } | ||
1184 | |||
1185 | static int vivi_mmap(struct file *file, struct vm_area_struct *vma) | ||
1186 | { | ||
1187 | struct vivi_dev *dev = video_drvdata(file); | ||
1188 | int ret; | ||
1189 | |||
1190 | dprintk(dev, 1, "mmap called, vma=0x%08lx\n", (unsigned long)vma); | ||
1191 | |||
1192 | ret = vb2_mmap(&dev->vb_vidq, vma); | ||
1193 | dprintk(dev, 1, "vma start=0x%08lx, size=%ld, ret=%d\n", | ||
1194 | (unsigned long)vma->vm_start, | ||
1195 | (unsigned long)vma->vm_end - (unsigned long)vma->vm_start, | ||
1196 | ret); | ||
1197 | return ret; | ||
1198 | } | ||
1199 | |||
1200 | static const struct v4l2_ctrl_ops vivi_ctrl_ops = { | 1071 | static const struct v4l2_ctrl_ops vivi_ctrl_ops = { |
1201 | .g_volatile_ctrl = vivi_g_volatile_ctrl, | 1072 | .g_volatile_ctrl = vivi_g_volatile_ctrl, |
1202 | .s_ctrl = vivi_s_ctrl, | 1073 | .s_ctrl = vivi_s_ctrl, |
@@ -1301,11 +1172,11 @@ static const struct v4l2_ctrl_config vivi_ctrl_int_menu = { | |||
1301 | static const struct v4l2_file_operations vivi_fops = { | 1172 | static const struct v4l2_file_operations vivi_fops = { |
1302 | .owner = THIS_MODULE, | 1173 | .owner = THIS_MODULE, |
1303 | .open = v4l2_fh_open, | 1174 | .open = v4l2_fh_open, |
1304 | .release = vivi_close, | 1175 | .release = vb2_fop_release, |
1305 | .read = vivi_read, | 1176 | .read = vb2_fop_read, |
1306 | .poll = vivi_poll, | 1177 | .poll = vb2_fop_poll, |
1307 | .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ | 1178 | .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ |
1308 | .mmap = vivi_mmap, | 1179 | .mmap = vb2_fop_mmap, |
1309 | }; | 1180 | }; |
1310 | 1181 | ||
1311 | static const struct v4l2_ioctl_ops vivi_ioctl_ops = { | 1182 | static const struct v4l2_ioctl_ops vivi_ioctl_ops = { |
@@ -1314,16 +1185,17 @@ static const struct v4l2_ioctl_ops vivi_ioctl_ops = { | |||
1314 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | 1185 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, |
1315 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | 1186 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
1316 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | 1187 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, |
1317 | .vidioc_reqbufs = vidioc_reqbufs, | 1188 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1318 | .vidioc_querybuf = vidioc_querybuf, | 1189 | .vidioc_create_bufs = vb2_ioctl_create_bufs, |
1319 | .vidioc_qbuf = vidioc_qbuf, | 1190 | .vidioc_prepare_buf = vb2_ioctl_prepare_buf, |
1320 | .vidioc_dqbuf = vidioc_dqbuf, | 1191 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1321 | .vidioc_s_std = vidioc_s_std, | 1192 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1193 | .vidioc_dqbuf = vb2_ioctl_dqbuf, | ||
1322 | .vidioc_enum_input = vidioc_enum_input, | 1194 | .vidioc_enum_input = vidioc_enum_input, |
1323 | .vidioc_g_input = vidioc_g_input, | 1195 | .vidioc_g_input = vidioc_g_input, |
1324 | .vidioc_s_input = vidioc_s_input, | 1196 | .vidioc_s_input = vidioc_s_input, |
1325 | .vidioc_streamon = vidioc_streamon, | 1197 | .vidioc_streamon = vb2_ioctl_streamon, |
1326 | .vidioc_streamoff = vidioc_streamoff, | 1198 | .vidioc_streamoff = vb2_ioctl_streamoff, |
1327 | .vidioc_log_status = v4l2_ctrl_log_status, | 1199 | .vidioc_log_status = v4l2_ctrl_log_status, |
1328 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | 1200 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, |
1329 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | 1201 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, |
@@ -1333,10 +1205,7 @@ static struct video_device vivi_template = { | |||
1333 | .name = "vivi", | 1205 | .name = "vivi", |
1334 | .fops = &vivi_fops, | 1206 | .fops = &vivi_fops, |
1335 | .ioctl_ops = &vivi_ioctl_ops, | 1207 | .ioctl_ops = &vivi_ioctl_ops, |
1336 | .release = video_device_release, | 1208 | .release = video_device_release_empty, |
1337 | |||
1338 | .tvnorms = V4L2_STD_525_60, | ||
1339 | .current_norm = V4L2_STD_NTSC_M, | ||
1340 | }; | 1209 | }; |
1341 | 1210 | ||
1342 | /* ----------------------------------------------------------------- | 1211 | /* ----------------------------------------------------------------- |
@@ -1354,8 +1223,8 @@ static int vivi_release(void) | |||
1354 | dev = list_entry(list, struct vivi_dev, vivi_devlist); | 1223 | dev = list_entry(list, struct vivi_dev, vivi_devlist); |
1355 | 1224 | ||
1356 | v4l2_info(&dev->v4l2_dev, "unregistering %s\n", | 1225 | v4l2_info(&dev->v4l2_dev, "unregistering %s\n", |
1357 | video_device_node_name(dev->vfd)); | 1226 | video_device_node_name(&dev->vdev)); |
1358 | video_unregister_device(dev->vfd); | 1227 | video_unregister_device(&dev->vdev); |
1359 | v4l2_device_unregister(&dev->v4l2_dev); | 1228 | v4l2_device_unregister(&dev->v4l2_dev); |
1360 | v4l2_ctrl_handler_free(&dev->ctrl_handler); | 1229 | v4l2_ctrl_handler_free(&dev->ctrl_handler); |
1361 | kfree(dev); | 1230 | kfree(dev); |
@@ -1440,14 +1309,11 @@ static int __init vivi_create_instance(int inst) | |||
1440 | INIT_LIST_HEAD(&dev->vidq.active); | 1309 | INIT_LIST_HEAD(&dev->vidq.active); |
1441 | init_waitqueue_head(&dev->vidq.wq); | 1310 | init_waitqueue_head(&dev->vidq.wq); |
1442 | 1311 | ||
1443 | ret = -ENOMEM; | 1312 | vfd = &dev->vdev; |
1444 | vfd = video_device_alloc(); | ||
1445 | if (!vfd) | ||
1446 | goto unreg_dev; | ||
1447 | |||
1448 | *vfd = vivi_template; | 1313 | *vfd = vivi_template; |
1449 | vfd->debug = debug; | 1314 | vfd->debug = debug; |
1450 | vfd->v4l2_dev = &dev->v4l2_dev; | 1315 | vfd->v4l2_dev = &dev->v4l2_dev; |
1316 | vfd->queue = q; | ||
1451 | set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | 1317 | set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); |
1452 | 1318 | ||
1453 | /* | 1319 | /* |
@@ -1455,12 +1321,11 @@ static int __init vivi_create_instance(int inst) | |||
1455 | * all fops and v4l2 ioctls. | 1321 | * all fops and v4l2 ioctls. |
1456 | */ | 1322 | */ |
1457 | vfd->lock = &dev->mutex; | 1323 | vfd->lock = &dev->mutex; |
1324 | video_set_drvdata(vfd, dev); | ||
1458 | 1325 | ||
1459 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr); | 1326 | ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr); |
1460 | if (ret < 0) | 1327 | if (ret < 0) |
1461 | goto rel_vdev; | 1328 | goto unreg_dev; |
1462 | |||
1463 | video_set_drvdata(vfd, dev); | ||
1464 | 1329 | ||
1465 | /* Now that everything is fine, let's add it to device list */ | 1330 | /* Now that everything is fine, let's add it to device list */ |
1466 | list_add_tail(&dev->vivi_devlist, &vivi_devlist); | 1331 | list_add_tail(&dev->vivi_devlist, &vivi_devlist); |
@@ -1468,13 +1333,10 @@ static int __init vivi_create_instance(int inst) | |||
1468 | if (video_nr != -1) | 1333 | if (video_nr != -1) |
1469 | video_nr++; | 1334 | video_nr++; |
1470 | 1335 | ||
1471 | dev->vfd = vfd; | ||
1472 | v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", | 1336 | v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n", |
1473 | video_device_node_name(vfd)); | 1337 | video_device_node_name(vfd)); |
1474 | return 0; | 1338 | return 0; |
1475 | 1339 | ||
1476 | rel_vdev: | ||
1477 | video_device_release(vfd); | ||
1478 | unreg_dev: | 1340 | unreg_dev: |
1479 | v4l2_ctrl_handler_free(hdl); | 1341 | v4l2_ctrl_handler_free(hdl); |
1480 | v4l2_device_unregister(&dev->v4l2_dev); | 1342 | v4l2_device_unregister(&dev->v4l2_dev); |
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c index e44cb330bbc8..9afab35878b4 100644 --- a/drivers/media/video/zr364xx.c +++ b/drivers/media/video/zr364xx.c | |||
@@ -37,6 +37,10 @@ | |||
37 | #include <linux/highmem.h> | 37 | #include <linux/highmem.h> |
38 | #include <media/v4l2-common.h> | 38 | #include <media/v4l2-common.h> |
39 | #include <media/v4l2-ioctl.h> | 39 | #include <media/v4l2-ioctl.h> |
40 | #include <media/v4l2-device.h> | ||
41 | #include <media/v4l2-ctrls.h> | ||
42 | #include <media/v4l2-fh.h> | ||
43 | #include <media/v4l2-event.h> | ||
40 | #include <media/videobuf-vmalloc.h> | 44 | #include <media/videobuf-vmalloc.h> |
41 | 45 | ||
42 | 46 | ||
@@ -120,11 +124,6 @@ static struct usb_device_id device_table[] = { | |||
120 | 124 | ||
121 | MODULE_DEVICE_TABLE(usb, device_table); | 125 | MODULE_DEVICE_TABLE(usb, device_table); |
122 | 126 | ||
123 | struct zr364xx_mode { | ||
124 | u32 color; /* output video color format */ | ||
125 | u32 brightness; /* brightness */ | ||
126 | }; | ||
127 | |||
128 | /* frame structure */ | 127 | /* frame structure */ |
129 | struct zr364xx_framei { | 128 | struct zr364xx_framei { |
130 | unsigned long ulState; /* ulState:ZR364XX_READ_IDLE, | 129 | unsigned long ulState; /* ulState:ZR364XX_READ_IDLE, |
@@ -173,7 +172,10 @@ static const struct zr364xx_fmt formats[] = { | |||
173 | struct zr364xx_camera { | 172 | struct zr364xx_camera { |
174 | struct usb_device *udev; /* save off the usb device pointer */ | 173 | struct usb_device *udev; /* save off the usb device pointer */ |
175 | struct usb_interface *interface;/* the interface for this device */ | 174 | struct usb_interface *interface;/* the interface for this device */ |
176 | struct video_device *vdev; /* v4l video device */ | 175 | struct v4l2_device v4l2_dev; |
176 | struct v4l2_ctrl_handler ctrl_handler; | ||
177 | struct video_device vdev; /* v4l video device */ | ||
178 | struct v4l2_fh *owner; /* owns the streaming */ | ||
177 | int nb; | 179 | int nb; |
178 | struct zr364xx_bufferi buffer; | 180 | struct zr364xx_bufferi buffer; |
179 | int skip; | 181 | int skip; |
@@ -181,12 +183,9 @@ struct zr364xx_camera { | |||
181 | int height; | 183 | int height; |
182 | int method; | 184 | int method; |
183 | struct mutex lock; | 185 | struct mutex lock; |
184 | struct mutex open_lock; | ||
185 | int users; | ||
186 | 186 | ||
187 | spinlock_t slock; | 187 | spinlock_t slock; |
188 | struct zr364xx_dmaqueue vidq; | 188 | struct zr364xx_dmaqueue vidq; |
189 | int resources; | ||
190 | int last_frame; | 189 | int last_frame; |
191 | int cur_frame; | 190 | int cur_frame; |
192 | unsigned long frame_count; | 191 | unsigned long frame_count; |
@@ -197,8 +196,7 @@ struct zr364xx_camera { | |||
197 | 196 | ||
198 | const struct zr364xx_fmt *fmt; | 197 | const struct zr364xx_fmt *fmt; |
199 | struct videobuf_queue vb_vidq; | 198 | struct videobuf_queue vb_vidq; |
200 | enum v4l2_buf_type type; | 199 | bool was_streaming; |
201 | struct zr364xx_mode mode; | ||
202 | }; | 200 | }; |
203 | 201 | ||
204 | /* buffer for one video frame */ | 202 | /* buffer for one video frame */ |
@@ -230,11 +228,6 @@ static int send_control_msg(struct usb_device *udev, u8 request, u16 value, | |||
230 | transfer_buffer, size, CTRL_TIMEOUT); | 228 | transfer_buffer, size, CTRL_TIMEOUT); |
231 | 229 | ||
232 | kfree(transfer_buffer); | 230 | kfree(transfer_buffer); |
233 | |||
234 | if (status < 0) | ||
235 | dev_err(&udev->dev, | ||
236 | "Failed sending control message, error %d.\n", status); | ||
237 | |||
238 | return status; | 231 | return status; |
239 | } | 232 | } |
240 | 233 | ||
@@ -468,6 +461,7 @@ static ssize_t zr364xx_read(struct file *file, char __user *buf, size_t count, | |||
468 | loff_t * ppos) | 461 | loff_t * ppos) |
469 | { | 462 | { |
470 | struct zr364xx_camera *cam = video_drvdata(file); | 463 | struct zr364xx_camera *cam = video_drvdata(file); |
464 | int err = 0; | ||
471 | 465 | ||
472 | _DBG("%s\n", __func__); | 466 | _DBG("%s\n", __func__); |
473 | 467 | ||
@@ -477,17 +471,21 @@ static ssize_t zr364xx_read(struct file *file, char __user *buf, size_t count, | |||
477 | if (!count) | 471 | if (!count) |
478 | return -EINVAL; | 472 | return -EINVAL; |
479 | 473 | ||
480 | if (cam->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && | 474 | if (mutex_lock_interruptible(&cam->lock)) |
481 | zr364xx_vidioc_streamon(file, cam, cam->type) == 0) { | 475 | return -ERESTARTSYS; |
482 | DBG("%s: reading %d bytes at pos %d.\n", __func__, (int) count, | 476 | |
483 | (int) *ppos); | 477 | err = zr364xx_vidioc_streamon(file, file->private_data, |
478 | V4L2_BUF_TYPE_VIDEO_CAPTURE); | ||
479 | if (err == 0) { | ||
480 | DBG("%s: reading %d bytes at pos %d.\n", __func__, | ||
481 | (int) count, (int) *ppos); | ||
484 | 482 | ||
485 | /* NoMan Sux ! */ | 483 | /* NoMan Sux ! */ |
486 | return videobuf_read_one(&cam->vb_vidq, buf, count, ppos, | 484 | err = videobuf_read_one(&cam->vb_vidq, buf, count, ppos, |
487 | file->f_flags & O_NONBLOCK); | 485 | file->f_flags & O_NONBLOCK); |
488 | } | 486 | } |
489 | 487 | mutex_unlock(&cam->lock); | |
490 | return 0; | 488 | return err; |
491 | } | 489 | } |
492 | 490 | ||
493 | /* video buffer vmalloc implementation based partly on VIVI driver which is | 491 | /* video buffer vmalloc implementation based partly on VIVI driver which is |
@@ -702,35 +700,6 @@ static int zr364xx_read_video_callback(struct zr364xx_camera *cam, | |||
702 | return 0; | 700 | return 0; |
703 | } | 701 | } |
704 | 702 | ||
705 | static int res_get(struct zr364xx_camera *cam) | ||
706 | { | ||
707 | /* is it free? */ | ||
708 | mutex_lock(&cam->lock); | ||
709 | if (cam->resources) { | ||
710 | /* no, someone else uses it */ | ||
711 | mutex_unlock(&cam->lock); | ||
712 | return 0; | ||
713 | } | ||
714 | /* it's free, grab it */ | ||
715 | cam->resources = 1; | ||
716 | _DBG("res: get\n"); | ||
717 | mutex_unlock(&cam->lock); | ||
718 | return 1; | ||
719 | } | ||
720 | |||
721 | static inline int res_check(struct zr364xx_camera *cam) | ||
722 | { | ||
723 | return cam->resources; | ||
724 | } | ||
725 | |||
726 | static void res_free(struct zr364xx_camera *cam) | ||
727 | { | ||
728 | mutex_lock(&cam->lock); | ||
729 | cam->resources = 0; | ||
730 | mutex_unlock(&cam->lock); | ||
731 | _DBG("res: put\n"); | ||
732 | } | ||
733 | |||
734 | static int zr364xx_vidioc_querycap(struct file *file, void *priv, | 703 | static int zr364xx_vidioc_querycap(struct file *file, void *priv, |
735 | struct v4l2_capability *cap) | 704 | struct v4l2_capability *cap) |
736 | { | 705 | { |
@@ -740,9 +709,10 @@ static int zr364xx_vidioc_querycap(struct file *file, void *priv, | |||
740 | strlcpy(cap->card, cam->udev->product, sizeof(cap->card)); | 709 | strlcpy(cap->card, cam->udev->product, sizeof(cap->card)); |
741 | strlcpy(cap->bus_info, dev_name(&cam->udev->dev), | 710 | strlcpy(cap->bus_info, dev_name(&cam->udev->dev), |
742 | sizeof(cap->bus_info)); | 711 | sizeof(cap->bus_info)); |
743 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | | 712 | cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | |
744 | V4L2_CAP_READWRITE | | 713 | V4L2_CAP_READWRITE | |
745 | V4L2_CAP_STREAMING; | 714 | V4L2_CAP_STREAMING; |
715 | cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; | ||
746 | 716 | ||
747 | return 0; | 717 | return 0; |
748 | } | 718 | } |
@@ -772,50 +742,18 @@ static int zr364xx_vidioc_s_input(struct file *file, void *priv, | |||
772 | return 0; | 742 | return 0; |
773 | } | 743 | } |
774 | 744 | ||
775 | static int zr364xx_vidioc_queryctrl(struct file *file, void *priv, | 745 | static int zr364xx_s_ctrl(struct v4l2_ctrl *ctrl) |
776 | struct v4l2_queryctrl *c) | ||
777 | { | 746 | { |
778 | struct zr364xx_camera *cam; | 747 | struct zr364xx_camera *cam = |
779 | 748 | container_of(ctrl->handler, struct zr364xx_camera, ctrl_handler); | |
780 | if (file == NULL) | ||
781 | return -ENODEV; | ||
782 | cam = video_drvdata(file); | ||
783 | |||
784 | switch (c->id) { | ||
785 | case V4L2_CID_BRIGHTNESS: | ||
786 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
787 | strcpy(c->name, "Brightness"); | ||
788 | c->minimum = 0; | ||
789 | c->maximum = 127; | ||
790 | c->step = 1; | ||
791 | c->default_value = cam->mode.brightness; | ||
792 | c->flags = 0; | ||
793 | break; | ||
794 | default: | ||
795 | return -EINVAL; | ||
796 | } | ||
797 | return 0; | ||
798 | } | ||
799 | |||
800 | static int zr364xx_vidioc_s_ctrl(struct file *file, void *priv, | ||
801 | struct v4l2_control *c) | ||
802 | { | ||
803 | struct zr364xx_camera *cam; | ||
804 | int temp; | 749 | int temp; |
805 | 750 | ||
806 | if (file == NULL) | 751 | switch (ctrl->id) { |
807 | return -ENODEV; | ||
808 | cam = video_drvdata(file); | ||
809 | |||
810 | switch (c->id) { | ||
811 | case V4L2_CID_BRIGHTNESS: | 752 | case V4L2_CID_BRIGHTNESS: |
812 | cam->mode.brightness = c->value; | ||
813 | /* hardware brightness */ | 753 | /* hardware brightness */ |
814 | mutex_lock(&cam->lock); | ||
815 | send_control_msg(cam->udev, 1, 0x2001, 0, NULL, 0); | 754 | send_control_msg(cam->udev, 1, 0x2001, 0, NULL, 0); |
816 | temp = (0x60 << 8) + 127 - cam->mode.brightness; | 755 | temp = (0x60 << 8) + 127 - ctrl->val; |
817 | send_control_msg(cam->udev, 1, temp, 0, NULL, 0); | 756 | send_control_msg(cam->udev, 1, temp, 0, NULL, 0); |
818 | mutex_unlock(&cam->lock); | ||
819 | break; | 757 | break; |
820 | default: | 758 | default: |
821 | return -EINVAL; | 759 | return -EINVAL; |
@@ -824,25 +762,6 @@ static int zr364xx_vidioc_s_ctrl(struct file *file, void *priv, | |||
824 | return 0; | 762 | return 0; |
825 | } | 763 | } |
826 | 764 | ||
827 | static int zr364xx_vidioc_g_ctrl(struct file *file, void *priv, | ||
828 | struct v4l2_control *c) | ||
829 | { | ||
830 | struct zr364xx_camera *cam; | ||
831 | |||
832 | if (file == NULL) | ||
833 | return -ENODEV; | ||
834 | cam = video_drvdata(file); | ||
835 | |||
836 | switch (c->id) { | ||
837 | case V4L2_CID_BRIGHTNESS: | ||
838 | c->value = cam->mode.brightness; | ||
839 | break; | ||
840 | default: | ||
841 | return -EINVAL; | ||
842 | } | ||
843 | return 0; | ||
844 | } | ||
845 | |||
846 | static int zr364xx_vidioc_enum_fmt_vid_cap(struct file *file, | 765 | static int zr364xx_vidioc_enum_fmt_vid_cap(struct file *file, |
847 | void *priv, struct v4l2_fmtdesc *f) | 766 | void *priv, struct v4l2_fmtdesc *f) |
848 | { | 767 | { |
@@ -888,7 +807,7 @@ static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
888 | f->fmt.pix.field = V4L2_FIELD_NONE; | 807 | f->fmt.pix.field = V4L2_FIELD_NONE; |
889 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; | 808 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; |
890 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; | 809 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; |
891 | f->fmt.pix.colorspace = 0; | 810 | f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; |
892 | f->fmt.pix.priv = 0; | 811 | f->fmt.pix.priv = 0; |
893 | DBG("%s: V4L2_PIX_FMT_%s (%d) ok!\n", __func__, | 812 | DBG("%s: V4L2_PIX_FMT_%s (%d) ok!\n", __func__, |
894 | decode_fourcc(f->fmt.pix.pixelformat, pixelformat_name), | 813 | decode_fourcc(f->fmt.pix.pixelformat, pixelformat_name), |
@@ -911,7 +830,7 @@ static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
911 | f->fmt.pix.height = cam->height; | 830 | f->fmt.pix.height = cam->height; |
912 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; | 831 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; |
913 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; | 832 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; |
914 | f->fmt.pix.colorspace = 0; | 833 | f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; |
915 | f->fmt.pix.priv = 0; | 834 | f->fmt.pix.priv = 0; |
916 | return 0; | 835 | return 0; |
917 | } | 836 | } |
@@ -936,7 +855,7 @@ static int zr364xx_vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
936 | goto out; | 855 | goto out; |
937 | } | 856 | } |
938 | 857 | ||
939 | if (res_check(cam)) { | 858 | if (cam->owner) { |
940 | DBG("%s can't change format after started\n", __func__); | 859 | DBG("%s can't change format after started\n", __func__); |
941 | ret = -EBUSY; | 860 | ret = -EBUSY; |
942 | goto out; | 861 | goto out; |
@@ -944,14 +863,13 @@ static int zr364xx_vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
944 | 863 | ||
945 | cam->width = f->fmt.pix.width; | 864 | cam->width = f->fmt.pix.width; |
946 | cam->height = f->fmt.pix.height; | 865 | cam->height = f->fmt.pix.height; |
947 | dev_info(&cam->udev->dev, "%s: %dx%d mode selected\n", __func__, | 866 | DBG("%s: %dx%d mode selected\n", __func__, |
948 | cam->width, cam->height); | 867 | cam->width, cam->height); |
949 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; | 868 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; |
950 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; | 869 | f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline; |
951 | f->fmt.pix.colorspace = 0; | 870 | f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG; |
952 | f->fmt.pix.priv = 0; | 871 | f->fmt.pix.priv = 0; |
953 | cam->vb_vidq.field = f->fmt.pix.field; | 872 | cam->vb_vidq.field = f->fmt.pix.field; |
954 | cam->mode.color = V4L2_PIX_FMT_JPEG; | ||
955 | 873 | ||
956 | if (f->fmt.pix.width == 160 && f->fmt.pix.height == 120) | 874 | if (f->fmt.pix.width == 160 && f->fmt.pix.height == 120) |
957 | mode = 1; | 875 | mode = 1; |
@@ -1015,10 +933,11 @@ out: | |||
1015 | static int zr364xx_vidioc_reqbufs(struct file *file, void *priv, | 933 | static int zr364xx_vidioc_reqbufs(struct file *file, void *priv, |
1016 | struct v4l2_requestbuffers *p) | 934 | struct v4l2_requestbuffers *p) |
1017 | { | 935 | { |
1018 | int rc; | ||
1019 | struct zr364xx_camera *cam = video_drvdata(file); | 936 | struct zr364xx_camera *cam = video_drvdata(file); |
1020 | rc = videobuf_reqbufs(&cam->vb_vidq, p); | 937 | |
1021 | return rc; | 938 | if (cam->owner && cam->owner != priv) |
939 | return -EBUSY; | ||
940 | return videobuf_reqbufs(&cam->vb_vidq, p); | ||
1022 | } | 941 | } |
1023 | 942 | ||
1024 | static int zr364xx_vidioc_querybuf(struct file *file, | 943 | static int zr364xx_vidioc_querybuf(struct file *file, |
@@ -1038,6 +957,8 @@ static int zr364xx_vidioc_qbuf(struct file *file, | |||
1038 | int rc; | 957 | int rc; |
1039 | struct zr364xx_camera *cam = video_drvdata(file); | 958 | struct zr364xx_camera *cam = video_drvdata(file); |
1040 | _DBG("%s\n", __func__); | 959 | _DBG("%s\n", __func__); |
960 | if (cam->owner && cam->owner != priv) | ||
961 | return -EBUSY; | ||
1041 | rc = videobuf_qbuf(&cam->vb_vidq, p); | 962 | rc = videobuf_qbuf(&cam->vb_vidq, p); |
1042 | return rc; | 963 | return rc; |
1043 | } | 964 | } |
@@ -1049,6 +970,8 @@ static int zr364xx_vidioc_dqbuf(struct file *file, | |||
1049 | int rc; | 970 | int rc; |
1050 | struct zr364xx_camera *cam = video_drvdata(file); | 971 | struct zr364xx_camera *cam = video_drvdata(file); |
1051 | _DBG("%s\n", __func__); | 972 | _DBG("%s\n", __func__); |
973 | if (cam->owner && cam->owner != priv) | ||
974 | return -EBUSY; | ||
1052 | rc = videobuf_dqbuf(&cam->vb_vidq, p, file->f_flags & O_NONBLOCK); | 975 | rc = videobuf_dqbuf(&cam->vb_vidq, p, file->f_flags & O_NONBLOCK); |
1053 | return rc; | 976 | return rc; |
1054 | } | 977 | } |
@@ -1197,29 +1120,23 @@ static inline int zr364xx_stop_acquire(struct zr364xx_camera *cam) | |||
1197 | return 0; | 1120 | return 0; |
1198 | } | 1121 | } |
1199 | 1122 | ||
1200 | static int zr364xx_vidioc_streamon(struct file *file, void *priv, | 1123 | static int zr364xx_prepare(struct zr364xx_camera *cam) |
1201 | enum v4l2_buf_type type) | ||
1202 | { | 1124 | { |
1203 | struct zr364xx_camera *cam = video_drvdata(file); | ||
1204 | int j; | ||
1205 | int res; | 1125 | int res; |
1126 | int i, j; | ||
1206 | 1127 | ||
1207 | DBG("%s\n", __func__); | 1128 | for (i = 0; init[cam->method][i].size != -1; i++) { |
1208 | 1129 | res = send_control_msg(cam->udev, 1, init[cam->method][i].value, | |
1209 | if (cam->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { | 1130 | 0, init[cam->method][i].bytes, |
1210 | dev_err(&cam->udev->dev, "invalid fh type0\n"); | 1131 | init[cam->method][i].size); |
1211 | return -EINVAL; | 1132 | if (res < 0) { |
1212 | } | 1133 | dev_err(&cam->udev->dev, |
1213 | if (cam->type != type) { | 1134 | "error during open sequence: %d\n", i); |
1214 | dev_err(&cam->udev->dev, "invalid fh type1\n"); | 1135 | return res; |
1215 | return -EINVAL; | 1136 | } |
1216 | } | ||
1217 | |||
1218 | if (!res_get(cam)) { | ||
1219 | dev_err(&cam->udev->dev, "stream busy\n"); | ||
1220 | return -EBUSY; | ||
1221 | } | 1137 | } |
1222 | 1138 | ||
1139 | cam->skip = 2; | ||
1223 | cam->last_frame = -1; | 1140 | cam->last_frame = -1; |
1224 | cam->cur_frame = 0; | 1141 | cam->cur_frame = 0; |
1225 | cam->frame_count = 0; | 1142 | cam->frame_count = 0; |
@@ -1227,11 +1144,31 @@ static int zr364xx_vidioc_streamon(struct file *file, void *priv, | |||
1227 | cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE; | 1144 | cam->buffer.frame[j].ulState = ZR364XX_READ_IDLE; |
1228 | cam->buffer.frame[j].cur_size = 0; | 1145 | cam->buffer.frame[j].cur_size = 0; |
1229 | } | 1146 | } |
1147 | v4l2_ctrl_handler_setup(&cam->ctrl_handler); | ||
1148 | return 0; | ||
1149 | } | ||
1150 | |||
1151 | static int zr364xx_vidioc_streamon(struct file *file, void *priv, | ||
1152 | enum v4l2_buf_type type) | ||
1153 | { | ||
1154 | struct zr364xx_camera *cam = video_drvdata(file); | ||
1155 | int res; | ||
1156 | |||
1157 | DBG("%s\n", __func__); | ||
1158 | |||
1159 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1160 | return -EINVAL; | ||
1161 | |||
1162 | if (cam->owner && cam->owner != priv) | ||
1163 | return -EBUSY; | ||
1164 | |||
1165 | res = zr364xx_prepare(cam); | ||
1166 | if (res) | ||
1167 | return res; | ||
1230 | res = videobuf_streamon(&cam->vb_vidq); | 1168 | res = videobuf_streamon(&cam->vb_vidq); |
1231 | if (res == 0) { | 1169 | if (res == 0) { |
1232 | zr364xx_start_acquire(cam); | 1170 | zr364xx_start_acquire(cam); |
1233 | } else { | 1171 | cam->owner = file->private_data; |
1234 | res_free(cam); | ||
1235 | } | 1172 | } |
1236 | return res; | 1173 | return res; |
1237 | } | 1174 | } |
@@ -1239,67 +1176,32 @@ static int zr364xx_vidioc_streamon(struct file *file, void *priv, | |||
1239 | static int zr364xx_vidioc_streamoff(struct file *file, void *priv, | 1176 | static int zr364xx_vidioc_streamoff(struct file *file, void *priv, |
1240 | enum v4l2_buf_type type) | 1177 | enum v4l2_buf_type type) |
1241 | { | 1178 | { |
1242 | int res; | ||
1243 | struct zr364xx_camera *cam = video_drvdata(file); | 1179 | struct zr364xx_camera *cam = video_drvdata(file); |
1244 | 1180 | ||
1245 | DBG("%s\n", __func__); | 1181 | DBG("%s\n", __func__); |
1246 | if (cam->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { | 1182 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1247 | dev_err(&cam->udev->dev, "invalid fh type0\n"); | ||
1248 | return -EINVAL; | 1183 | return -EINVAL; |
1249 | } | 1184 | if (cam->owner && cam->owner != priv) |
1250 | if (cam->type != type) { | 1185 | return -EBUSY; |
1251 | dev_err(&cam->udev->dev, "invalid fh type1\n"); | ||
1252 | return -EINVAL; | ||
1253 | } | ||
1254 | zr364xx_stop_acquire(cam); | 1186 | zr364xx_stop_acquire(cam); |
1255 | res = videobuf_streamoff(&cam->vb_vidq); | 1187 | return videobuf_streamoff(&cam->vb_vidq); |
1256 | if (res < 0) | ||
1257 | return res; | ||
1258 | res_free(cam); | ||
1259 | return 0; | ||
1260 | } | 1188 | } |
1261 | 1189 | ||
1262 | 1190 | ||
1263 | /* open the camera */ | 1191 | /* open the camera */ |
1264 | static int zr364xx_open(struct file *file) | 1192 | static int zr364xx_open(struct file *file) |
1265 | { | 1193 | { |
1266 | struct video_device *vdev = video_devdata(file); | ||
1267 | struct zr364xx_camera *cam = video_drvdata(file); | 1194 | struct zr364xx_camera *cam = video_drvdata(file); |
1268 | struct usb_device *udev = cam->udev; | 1195 | int err; |
1269 | int i, err; | ||
1270 | 1196 | ||
1271 | DBG("%s\n", __func__); | 1197 | DBG("%s\n", __func__); |
1272 | 1198 | ||
1273 | mutex_lock(&cam->open_lock); | 1199 | if (mutex_lock_interruptible(&cam->lock)) |
1200 | return -ERESTARTSYS; | ||
1274 | 1201 | ||
1275 | if (cam->users) { | 1202 | err = v4l2_fh_open(file); |
1276 | err = -EBUSY; | 1203 | if (err) |
1277 | goto out; | 1204 | goto out; |
1278 | } | ||
1279 | |||
1280 | for (i = 0; init[cam->method][i].size != -1; i++) { | ||
1281 | err = | ||
1282 | send_control_msg(udev, 1, init[cam->method][i].value, | ||
1283 | 0, init[cam->method][i].bytes, | ||
1284 | init[cam->method][i].size); | ||
1285 | if (err < 0) { | ||
1286 | dev_err(&cam->udev->dev, | ||
1287 | "error during open sequence: %d\n", i); | ||
1288 | goto out; | ||
1289 | } | ||
1290 | } | ||
1291 | |||
1292 | cam->skip = 2; | ||
1293 | cam->users++; | ||
1294 | file->private_data = vdev; | ||
1295 | cam->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1296 | cam->fmt = formats; | ||
1297 | |||
1298 | videobuf_queue_vmalloc_init(&cam->vb_vidq, &zr364xx_video_qops, | ||
1299 | NULL, &cam->slock, | ||
1300 | cam->type, | ||
1301 | V4L2_FIELD_NONE, | ||
1302 | sizeof(struct zr364xx_buffer), cam, NULL); | ||
1303 | 1205 | ||
1304 | /* Added some delay here, since opening/closing the camera quickly, | 1206 | /* Added some delay here, since opening/closing the camera quickly, |
1305 | * like Ekiga does during its startup, can crash the webcam | 1207 | * like Ekiga does during its startup, can crash the webcam |
@@ -1308,29 +1210,20 @@ static int zr364xx_open(struct file *file) | |||
1308 | err = 0; | 1210 | err = 0; |
1309 | 1211 | ||
1310 | out: | 1212 | out: |
1311 | mutex_unlock(&cam->open_lock); | 1213 | mutex_unlock(&cam->lock); |
1312 | DBG("%s: %d\n", __func__, err); | 1214 | DBG("%s: %d\n", __func__, err); |
1313 | return err; | 1215 | return err; |
1314 | } | 1216 | } |
1315 | 1217 | ||
1316 | static void zr364xx_destroy(struct zr364xx_camera *cam) | 1218 | static void zr364xx_release(struct v4l2_device *v4l2_dev) |
1317 | { | 1219 | { |
1220 | struct zr364xx_camera *cam = | ||
1221 | container_of(v4l2_dev, struct zr364xx_camera, v4l2_dev); | ||
1318 | unsigned long i; | 1222 | unsigned long i; |
1319 | 1223 | ||
1320 | if (!cam) { | 1224 | v4l2_device_unregister(&cam->v4l2_dev); |
1321 | printk(KERN_ERR KBUILD_MODNAME ", %s: no device\n", __func__); | ||
1322 | return; | ||
1323 | } | ||
1324 | mutex_lock(&cam->open_lock); | ||
1325 | if (cam->vdev) | ||
1326 | video_unregister_device(cam->vdev); | ||
1327 | cam->vdev = NULL; | ||
1328 | |||
1329 | /* stops the read pipe if it is running */ | ||
1330 | if (cam->b_acquire) | ||
1331 | zr364xx_stop_acquire(cam); | ||
1332 | 1225 | ||
1333 | zr364xx_stop_readpipe(cam); | 1226 | videobuf_mmap_free(&cam->vb_vidq); |
1334 | 1227 | ||
1335 | /* release sys buffers */ | 1228 | /* release sys buffers */ |
1336 | for (i = 0; i < FRAMES; i++) { | 1229 | for (i = 0; i < FRAMES; i++) { |
@@ -1341,62 +1234,45 @@ static void zr364xx_destroy(struct zr364xx_camera *cam) | |||
1341 | cam->buffer.frame[i].lpvbits = NULL; | 1234 | cam->buffer.frame[i].lpvbits = NULL; |
1342 | } | 1235 | } |
1343 | 1236 | ||
1237 | v4l2_ctrl_handler_free(&cam->ctrl_handler); | ||
1344 | /* release transfer buffer */ | 1238 | /* release transfer buffer */ |
1345 | kfree(cam->pipe->transfer_buffer); | 1239 | kfree(cam->pipe->transfer_buffer); |
1346 | cam->pipe->transfer_buffer = NULL; | ||
1347 | mutex_unlock(&cam->open_lock); | ||
1348 | kfree(cam); | 1240 | kfree(cam); |
1349 | cam = NULL; | ||
1350 | } | 1241 | } |
1351 | 1242 | ||
1352 | /* release the camera */ | 1243 | /* release the camera */ |
1353 | static int zr364xx_release(struct file *file) | 1244 | static int zr364xx_close(struct file *file) |
1354 | { | 1245 | { |
1355 | struct zr364xx_camera *cam; | 1246 | struct zr364xx_camera *cam; |
1356 | struct usb_device *udev; | 1247 | struct usb_device *udev; |
1357 | int i, err; | 1248 | int i; |
1358 | 1249 | ||
1359 | DBG("%s\n", __func__); | 1250 | DBG("%s\n", __func__); |
1360 | cam = video_drvdata(file); | 1251 | cam = video_drvdata(file); |
1361 | 1252 | ||
1362 | if (!cam) | 1253 | mutex_lock(&cam->lock); |
1363 | return -ENODEV; | ||
1364 | |||
1365 | mutex_lock(&cam->open_lock); | ||
1366 | udev = cam->udev; | 1254 | udev = cam->udev; |
1367 | 1255 | ||
1368 | /* turn off stream */ | 1256 | if (file->private_data == cam->owner) { |
1369 | if (res_check(cam)) { | 1257 | /* turn off stream */ |
1370 | if (cam->b_acquire) | 1258 | if (cam->b_acquire) |
1371 | zr364xx_stop_acquire(cam); | 1259 | zr364xx_stop_acquire(cam); |
1372 | videobuf_streamoff(&cam->vb_vidq); | 1260 | videobuf_streamoff(&cam->vb_vidq); |
1373 | res_free(cam); | ||
1374 | } | ||
1375 | |||
1376 | cam->users--; | ||
1377 | file->private_data = NULL; | ||
1378 | 1261 | ||
1379 | for (i = 0; i < 2; i++) { | 1262 | for (i = 0; i < 2; i++) { |
1380 | err = | 1263 | send_control_msg(udev, 1, init[cam->method][i].value, |
1381 | send_control_msg(udev, 1, init[cam->method][i].value, | 1264 | 0, init[cam->method][i].bytes, |
1382 | 0, init[cam->method][i].bytes, | 1265 | init[cam->method][i].size); |
1383 | init[cam->method][i].size); | ||
1384 | if (err < 0) { | ||
1385 | dev_err(&udev->dev, "error during release sequence\n"); | ||
1386 | goto out; | ||
1387 | } | 1266 | } |
1267 | cam->owner = NULL; | ||
1388 | } | 1268 | } |
1389 | 1269 | ||
1390 | /* Added some delay here, since opening/closing the camera quickly, | 1270 | /* Added some delay here, since opening/closing the camera quickly, |
1391 | * like Ekiga does during its startup, can crash the webcam | 1271 | * like Ekiga does during its startup, can crash the webcam |
1392 | */ | 1272 | */ |
1393 | mdelay(100); | 1273 | mdelay(100); |
1394 | err = 0; | 1274 | mutex_unlock(&cam->lock); |
1395 | 1275 | return v4l2_fh_release(file); | |
1396 | out: | ||
1397 | mutex_unlock(&cam->open_lock); | ||
1398 | |||
1399 | return err; | ||
1400 | } | 1276 | } |
1401 | 1277 | ||
1402 | 1278 | ||
@@ -1424,21 +1300,24 @@ static unsigned int zr364xx_poll(struct file *file, | |||
1424 | { | 1300 | { |
1425 | struct zr364xx_camera *cam = video_drvdata(file); | 1301 | struct zr364xx_camera *cam = video_drvdata(file); |
1426 | struct videobuf_queue *q = &cam->vb_vidq; | 1302 | struct videobuf_queue *q = &cam->vb_vidq; |
1427 | _DBG("%s\n", __func__); | 1303 | unsigned res = v4l2_ctrl_poll(file, wait); |
1428 | 1304 | ||
1429 | if (cam->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1305 | _DBG("%s\n", __func__); |
1430 | return POLLERR; | ||
1431 | 1306 | ||
1432 | return videobuf_poll_stream(file, q, wait); | 1307 | return res | videobuf_poll_stream(file, q, wait); |
1433 | } | 1308 | } |
1434 | 1309 | ||
1310 | static const struct v4l2_ctrl_ops zr364xx_ctrl_ops = { | ||
1311 | .s_ctrl = zr364xx_s_ctrl, | ||
1312 | }; | ||
1313 | |||
1435 | static const struct v4l2_file_operations zr364xx_fops = { | 1314 | static const struct v4l2_file_operations zr364xx_fops = { |
1436 | .owner = THIS_MODULE, | 1315 | .owner = THIS_MODULE, |
1437 | .open = zr364xx_open, | 1316 | .open = zr364xx_open, |
1438 | .release = zr364xx_release, | 1317 | .release = zr364xx_close, |
1439 | .read = zr364xx_read, | 1318 | .read = zr364xx_read, |
1440 | .mmap = zr364xx_mmap, | 1319 | .mmap = zr364xx_mmap, |
1441 | .ioctl = video_ioctl2, | 1320 | .unlocked_ioctl = video_ioctl2, |
1442 | .poll = zr364xx_poll, | 1321 | .poll = zr364xx_poll, |
1443 | }; | 1322 | }; |
1444 | 1323 | ||
@@ -1453,20 +1332,20 @@ static const struct v4l2_ioctl_ops zr364xx_ioctl_ops = { | |||
1453 | .vidioc_s_input = zr364xx_vidioc_s_input, | 1332 | .vidioc_s_input = zr364xx_vidioc_s_input, |
1454 | .vidioc_streamon = zr364xx_vidioc_streamon, | 1333 | .vidioc_streamon = zr364xx_vidioc_streamon, |
1455 | .vidioc_streamoff = zr364xx_vidioc_streamoff, | 1334 | .vidioc_streamoff = zr364xx_vidioc_streamoff, |
1456 | .vidioc_queryctrl = zr364xx_vidioc_queryctrl, | ||
1457 | .vidioc_g_ctrl = zr364xx_vidioc_g_ctrl, | ||
1458 | .vidioc_s_ctrl = zr364xx_vidioc_s_ctrl, | ||
1459 | .vidioc_reqbufs = zr364xx_vidioc_reqbufs, | 1335 | .vidioc_reqbufs = zr364xx_vidioc_reqbufs, |
1460 | .vidioc_querybuf = zr364xx_vidioc_querybuf, | 1336 | .vidioc_querybuf = zr364xx_vidioc_querybuf, |
1461 | .vidioc_qbuf = zr364xx_vidioc_qbuf, | 1337 | .vidioc_qbuf = zr364xx_vidioc_qbuf, |
1462 | .vidioc_dqbuf = zr364xx_vidioc_dqbuf, | 1338 | .vidioc_dqbuf = zr364xx_vidioc_dqbuf, |
1339 | .vidioc_log_status = v4l2_ctrl_log_status, | ||
1340 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | ||
1341 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | ||
1463 | }; | 1342 | }; |
1464 | 1343 | ||
1465 | static struct video_device zr364xx_template = { | 1344 | static struct video_device zr364xx_template = { |
1466 | .name = DRIVER_DESC, | 1345 | .name = DRIVER_DESC, |
1467 | .fops = &zr364xx_fops, | 1346 | .fops = &zr364xx_fops, |
1468 | .ioctl_ops = &zr364xx_ioctl_ops, | 1347 | .ioctl_ops = &zr364xx_ioctl_ops, |
1469 | .release = video_device_release, | 1348 | .release = video_device_release_empty, |
1470 | }; | 1349 | }; |
1471 | 1350 | ||
1472 | 1351 | ||
@@ -1540,6 +1419,7 @@ static int zr364xx_probe(struct usb_interface *intf, | |||
1540 | struct zr364xx_camera *cam = NULL; | 1419 | struct zr364xx_camera *cam = NULL; |
1541 | struct usb_host_interface *iface_desc; | 1420 | struct usb_host_interface *iface_desc; |
1542 | struct usb_endpoint_descriptor *endpoint; | 1421 | struct usb_endpoint_descriptor *endpoint; |
1422 | struct v4l2_ctrl_handler *hdl; | ||
1543 | int err; | 1423 | int err; |
1544 | int i; | 1424 | int i; |
1545 | 1425 | ||
@@ -1555,21 +1435,34 @@ static int zr364xx_probe(struct usb_interface *intf, | |||
1555 | dev_err(&udev->dev, "cam: out of memory !\n"); | 1435 | dev_err(&udev->dev, "cam: out of memory !\n"); |
1556 | return -ENOMEM; | 1436 | return -ENOMEM; |
1557 | } | 1437 | } |
1558 | /* save the init method used by this camera */ | ||
1559 | cam->method = id->driver_info; | ||
1560 | 1438 | ||
1561 | cam->vdev = video_device_alloc(); | 1439 | cam->v4l2_dev.release = zr364xx_release; |
1562 | if (cam->vdev == NULL) { | 1440 | err = v4l2_device_register(&intf->dev, &cam->v4l2_dev); |
1563 | dev_err(&udev->dev, "cam->vdev: out of memory !\n"); | 1441 | if (err < 0) { |
1442 | dev_err(&udev->dev, "couldn't register v4l2_device\n"); | ||
1564 | kfree(cam); | 1443 | kfree(cam); |
1565 | cam = NULL; | 1444 | return err; |
1566 | return -ENOMEM; | ||
1567 | } | 1445 | } |
1568 | memcpy(cam->vdev, &zr364xx_template, sizeof(zr364xx_template)); | 1446 | hdl = &cam->ctrl_handler; |
1569 | cam->vdev->parent = &intf->dev; | 1447 | v4l2_ctrl_handler_init(hdl, 1); |
1570 | video_set_drvdata(cam->vdev, cam); | 1448 | v4l2_ctrl_new_std(hdl, &zr364xx_ctrl_ops, |
1449 | V4L2_CID_BRIGHTNESS, 0, 127, 1, 64); | ||
1450 | if (hdl->error) { | ||
1451 | err = hdl->error; | ||
1452 | dev_err(&udev->dev, "couldn't register control\n"); | ||
1453 | goto fail; | ||
1454 | } | ||
1455 | /* save the init method used by this camera */ | ||
1456 | cam->method = id->driver_info; | ||
1457 | mutex_init(&cam->lock); | ||
1458 | cam->vdev = zr364xx_template; | ||
1459 | cam->vdev.lock = &cam->lock; | ||
1460 | cam->vdev.v4l2_dev = &cam->v4l2_dev; | ||
1461 | cam->vdev.ctrl_handler = &cam->ctrl_handler; | ||
1462 | set_bit(V4L2_FL_USE_FH_PRIO, &cam->vdev.flags); | ||
1463 | video_set_drvdata(&cam->vdev, cam); | ||
1571 | if (debug) | 1464 | if (debug) |
1572 | cam->vdev->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; | 1465 | cam->vdev.debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG; |
1573 | 1466 | ||
1574 | cam->udev = udev; | 1467 | cam->udev = udev; |
1575 | 1468 | ||
@@ -1615,11 +1508,7 @@ static int zr364xx_probe(struct usb_interface *intf, | |||
1615 | header2[439] = cam->width / 256; | 1508 | header2[439] = cam->width / 256; |
1616 | header2[440] = cam->width % 256; | 1509 | header2[440] = cam->width % 256; |
1617 | 1510 | ||
1618 | cam->users = 0; | ||
1619 | cam->nb = 0; | 1511 | cam->nb = 0; |
1620 | cam->mode.brightness = 64; | ||
1621 | mutex_init(&cam->lock); | ||
1622 | mutex_init(&cam->open_lock); | ||
1623 | 1512 | ||
1624 | DBG("dev: %p, udev %p interface %p\n", cam, cam->udev, intf); | 1513 | DBG("dev: %p, udev %p interface %p\n", cam, cam->udev, intf); |
1625 | 1514 | ||
@@ -1635,52 +1524,100 @@ static int zr364xx_probe(struct usb_interface *intf, | |||
1635 | } | 1524 | } |
1636 | 1525 | ||
1637 | if (!cam->read_endpoint) { | 1526 | if (!cam->read_endpoint) { |
1527 | err = -ENOMEM; | ||
1638 | dev_err(&intf->dev, "Could not find bulk-in endpoint\n"); | 1528 | dev_err(&intf->dev, "Could not find bulk-in endpoint\n"); |
1639 | video_device_release(cam->vdev); | 1529 | goto fail; |
1640 | kfree(cam); | ||
1641 | cam = NULL; | ||
1642 | return -ENOMEM; | ||
1643 | } | 1530 | } |
1644 | 1531 | ||
1645 | /* v4l */ | 1532 | /* v4l */ |
1646 | INIT_LIST_HEAD(&cam->vidq.active); | 1533 | INIT_LIST_HEAD(&cam->vidq.active); |
1647 | cam->vidq.cam = cam; | 1534 | cam->vidq.cam = cam; |
1648 | err = video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1); | ||
1649 | if (err) { | ||
1650 | dev_err(&udev->dev, "video_register_device failed\n"); | ||
1651 | video_device_release(cam->vdev); | ||
1652 | kfree(cam); | ||
1653 | cam = NULL; | ||
1654 | return err; | ||
1655 | } | ||
1656 | 1535 | ||
1657 | usb_set_intfdata(intf, cam); | 1536 | usb_set_intfdata(intf, cam); |
1658 | 1537 | ||
1659 | /* load zr364xx board specific */ | 1538 | /* load zr364xx board specific */ |
1660 | err = zr364xx_board_init(cam); | 1539 | err = zr364xx_board_init(cam); |
1661 | if (err) { | 1540 | if (!err) |
1662 | spin_lock_init(&cam->slock); | 1541 | err = v4l2_ctrl_handler_setup(hdl); |
1663 | return err; | 1542 | if (err) |
1664 | } | 1543 | goto fail; |
1665 | 1544 | ||
1666 | spin_lock_init(&cam->slock); | 1545 | spin_lock_init(&cam->slock); |
1667 | 1546 | ||
1547 | cam->fmt = formats; | ||
1548 | |||
1549 | videobuf_queue_vmalloc_init(&cam->vb_vidq, &zr364xx_video_qops, | ||
1550 | NULL, &cam->slock, | ||
1551 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | ||
1552 | V4L2_FIELD_NONE, | ||
1553 | sizeof(struct zr364xx_buffer), cam, &cam->lock); | ||
1554 | |||
1555 | err = video_register_device(&cam->vdev, VFL_TYPE_GRABBER, -1); | ||
1556 | if (err) { | ||
1557 | dev_err(&udev->dev, "video_register_device failed\n"); | ||
1558 | goto fail; | ||
1559 | } | ||
1560 | |||
1668 | dev_info(&udev->dev, DRIVER_DESC " controlling device %s\n", | 1561 | dev_info(&udev->dev, DRIVER_DESC " controlling device %s\n", |
1669 | video_device_node_name(cam->vdev)); | 1562 | video_device_node_name(&cam->vdev)); |
1670 | return 0; | 1563 | return 0; |
1564 | |||
1565 | fail: | ||
1566 | v4l2_ctrl_handler_free(hdl); | ||
1567 | v4l2_device_unregister(&cam->v4l2_dev); | ||
1568 | kfree(cam); | ||
1569 | return err; | ||
1671 | } | 1570 | } |
1672 | 1571 | ||
1673 | 1572 | ||
1674 | static void zr364xx_disconnect(struct usb_interface *intf) | 1573 | static void zr364xx_disconnect(struct usb_interface *intf) |
1675 | { | 1574 | { |
1676 | struct zr364xx_camera *cam = usb_get_intfdata(intf); | 1575 | struct zr364xx_camera *cam = usb_get_intfdata(intf); |
1677 | videobuf_mmap_free(&cam->vb_vidq); | 1576 | |
1577 | mutex_lock(&cam->lock); | ||
1678 | usb_set_intfdata(intf, NULL); | 1578 | usb_set_intfdata(intf, NULL); |
1679 | dev_info(&intf->dev, DRIVER_DESC " webcam unplugged\n"); | 1579 | dev_info(&intf->dev, DRIVER_DESC " webcam unplugged\n"); |
1680 | zr364xx_destroy(cam); | 1580 | video_unregister_device(&cam->vdev); |
1581 | v4l2_device_disconnect(&cam->v4l2_dev); | ||
1582 | |||
1583 | /* stops the read pipe if it is running */ | ||
1584 | if (cam->b_acquire) | ||
1585 | zr364xx_stop_acquire(cam); | ||
1586 | |||
1587 | zr364xx_stop_readpipe(cam); | ||
1588 | mutex_unlock(&cam->lock); | ||
1589 | v4l2_device_put(&cam->v4l2_dev); | ||
1681 | } | 1590 | } |
1682 | 1591 | ||
1683 | 1592 | ||
1593 | #ifdef CONFIG_PM | ||
1594 | static int zr364xx_suspend(struct usb_interface *intf, pm_message_t message) | ||
1595 | { | ||
1596 | struct zr364xx_camera *cam = usb_get_intfdata(intf); | ||
1597 | |||
1598 | cam->was_streaming = cam->b_acquire; | ||
1599 | if (!cam->was_streaming) | ||
1600 | return 0; | ||
1601 | zr364xx_stop_acquire(cam); | ||
1602 | zr364xx_stop_readpipe(cam); | ||
1603 | return 0; | ||
1604 | } | ||
1605 | |||
1606 | static int zr364xx_resume(struct usb_interface *intf) | ||
1607 | { | ||
1608 | struct zr364xx_camera *cam = usb_get_intfdata(intf); | ||
1609 | int res; | ||
1610 | |||
1611 | if (!cam->was_streaming) | ||
1612 | return 0; | ||
1613 | |||
1614 | zr364xx_start_readpipe(cam); | ||
1615 | res = zr364xx_prepare(cam); | ||
1616 | if (!res) | ||
1617 | zr364xx_start_acquire(cam); | ||
1618 | return res; | ||
1619 | } | ||
1620 | #endif | ||
1684 | 1621 | ||
1685 | /**********************/ | 1622 | /**********************/ |
1686 | /* Module integration */ | 1623 | /* Module integration */ |
@@ -1690,6 +1627,11 @@ static struct usb_driver zr364xx_driver = { | |||
1690 | .name = "zr364xx", | 1627 | .name = "zr364xx", |
1691 | .probe = zr364xx_probe, | 1628 | .probe = zr364xx_probe, |
1692 | .disconnect = zr364xx_disconnect, | 1629 | .disconnect = zr364xx_disconnect, |
1630 | #ifdef CONFIG_PM | ||
1631 | .suspend = zr364xx_suspend, | ||
1632 | .resume = zr364xx_resume, | ||
1633 | .reset_resume = zr364xx_resume, | ||
1634 | #endif | ||
1693 | .id_table = device_table | 1635 | .id_table = device_table |
1694 | }; | 1636 | }; |
1695 | 1637 | ||
diff --git a/drivers/staging/media/lirc/lirc_sir.c b/drivers/staging/media/lirc/lirc_sir.c index 945d9623550b..4afc3b419738 100644 --- a/drivers/staging/media/lirc/lirc_sir.c +++ b/drivers/staging/media/lirc/lirc_sir.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <linux/io.h> | 52 | #include <linux/io.h> |
53 | #include <asm/irq.h> | 53 | #include <asm/irq.h> |
54 | #include <linux/fcntl.h> | 54 | #include <linux/fcntl.h> |
55 | #include <linux/platform_device.h> | ||
55 | #ifdef LIRC_ON_SA1100 | 56 | #ifdef LIRC_ON_SA1100 |
56 | #include <asm/hardware.h> | 57 | #include <asm/hardware.h> |
57 | #ifdef CONFIG_SA1100_COLLIE | 58 | #ifdef CONFIG_SA1100_COLLIE |
@@ -487,9 +488,11 @@ static struct lirc_driver driver = { | |||
487 | .owner = THIS_MODULE, | 488 | .owner = THIS_MODULE, |
488 | }; | 489 | }; |
489 | 490 | ||
491 | static struct platform_device *lirc_sir_dev; | ||
490 | 492 | ||
491 | static int init_chrdev(void) | 493 | static int init_chrdev(void) |
492 | { | 494 | { |
495 | driver.dev = &lirc_sir_dev->dev; | ||
493 | driver.minor = lirc_register_driver(&driver); | 496 | driver.minor = lirc_register_driver(&driver); |
494 | if (driver.minor < 0) { | 497 | if (driver.minor < 0) { |
495 | printk(KERN_ERR LIRC_DRIVER_NAME ": init_chrdev() failed.\n"); | 498 | printk(KERN_ERR LIRC_DRIVER_NAME ": init_chrdev() failed.\n"); |
@@ -1215,20 +1218,71 @@ static int init_lirc_sir(void) | |||
1215 | return 0; | 1218 | return 0; |
1216 | } | 1219 | } |
1217 | 1220 | ||
1221 | static int __devinit lirc_sir_probe(struct platform_device *dev) | ||
1222 | { | ||
1223 | return 0; | ||
1224 | } | ||
1225 | |||
1226 | static int __devexit lirc_sir_remove(struct platform_device *dev) | ||
1227 | { | ||
1228 | return 0; | ||
1229 | } | ||
1230 | |||
1231 | static struct platform_driver lirc_sir_driver = { | ||
1232 | .probe = lirc_sir_probe, | ||
1233 | .remove = __devexit_p(lirc_sir_remove), | ||
1234 | .driver = { | ||
1235 | .name = "lirc_sir", | ||
1236 | .owner = THIS_MODULE, | ||
1237 | }, | ||
1238 | }; | ||
1218 | 1239 | ||
1219 | static int __init lirc_sir_init(void) | 1240 | static int __init lirc_sir_init(void) |
1220 | { | 1241 | { |
1221 | int retval; | 1242 | int retval; |
1222 | 1243 | ||
1244 | retval = platform_driver_register(&lirc_sir_driver); | ||
1245 | if (retval) { | ||
1246 | printk(KERN_ERR LIRC_DRIVER_NAME ": Platform driver register " | ||
1247 | "failed!\n"); | ||
1248 | return -ENODEV; | ||
1249 | } | ||
1250 | |||
1251 | lirc_sir_dev = platform_device_alloc("lirc_dev", 0); | ||
1252 | if (!lirc_sir_dev) { | ||
1253 | printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device alloc " | ||
1254 | "failed!\n"); | ||
1255 | retval = -ENOMEM; | ||
1256 | goto pdev_alloc_fail; | ||
1257 | } | ||
1258 | |||
1259 | retval = platform_device_add(lirc_sir_dev); | ||
1260 | if (retval) { | ||
1261 | printk(KERN_ERR LIRC_DRIVER_NAME ": Platform device add " | ||
1262 | "failed!\n"); | ||
1263 | retval = -ENODEV; | ||
1264 | goto pdev_add_fail; | ||
1265 | } | ||
1266 | |||
1223 | retval = init_chrdev(); | 1267 | retval = init_chrdev(); |
1224 | if (retval < 0) | 1268 | if (retval < 0) |
1225 | return retval; | 1269 | goto fail; |
1270 | |||
1226 | retval = init_lirc_sir(); | 1271 | retval = init_lirc_sir(); |
1227 | if (retval) { | 1272 | if (retval) { |
1228 | drop_chrdev(); | 1273 | drop_chrdev(); |
1229 | return retval; | 1274 | goto fail; |
1230 | } | 1275 | } |
1276 | |||
1231 | return 0; | 1277 | return 0; |
1278 | |||
1279 | fail: | ||
1280 | platform_device_del(lirc_sir_dev); | ||
1281 | pdev_add_fail: | ||
1282 | platform_device_put(lirc_sir_dev); | ||
1283 | pdev_alloc_fail: | ||
1284 | platform_driver_unregister(&lirc_sir_driver); | ||
1285 | return retval; | ||
1232 | } | 1286 | } |
1233 | 1287 | ||
1234 | static void __exit lirc_sir_exit(void) | 1288 | static void __exit lirc_sir_exit(void) |
@@ -1236,6 +1290,8 @@ static void __exit lirc_sir_exit(void) | |||
1236 | drop_hardware(); | 1290 | drop_hardware(); |
1237 | drop_chrdev(); | 1291 | drop_chrdev(); |
1238 | drop_port(); | 1292 | drop_port(); |
1293 | platform_device_unregister(lirc_sir_dev); | ||
1294 | platform_driver_unregister(&lirc_sir_driver); | ||
1239 | printk(KERN_INFO LIRC_DRIVER_NAME ": Uninstalled.\n"); | 1295 | printk(KERN_INFO LIRC_DRIVER_NAME ": Uninstalled.\n"); |
1240 | } | 1296 | } |
1241 | 1297 | ||
diff --git a/drivers/staging/media/solo6x10/TODO b/drivers/staging/media/solo6x10/TODO index 7e6c4fa130df..539f739fe9e6 100644 --- a/drivers/staging/media/solo6x10/TODO +++ b/drivers/staging/media/solo6x10/TODO | |||
@@ -20,5 +20,5 @@ TODO (general): | |||
20 | - implement loopback of external sound jack with incoming audio? | 20 | - implement loopback of external sound jack with incoming audio? |
21 | - implement pause/resume | 21 | - implement pause/resume |
22 | 22 | ||
23 | Plase send patches to Greg Kroah-Hartman <greg@kroah.com> and Cc Ben Collins | 23 | Plase send patches to Mauro Carvalho Chehab <mchehab@redhat.com> and Cc Ben Collins |
24 | <bcollins@bluecherry.net> | 24 | <bcollins@bluecherry.net> |
diff --git a/drivers/staging/media/solo6x10/i2c.c b/drivers/staging/media/solo6x10/i2c.c index ef95a500b4da..398070a3d293 100644 --- a/drivers/staging/media/solo6x10/i2c.c +++ b/drivers/staging/media/solo6x10/i2c.c | |||
@@ -175,7 +175,7 @@ int solo_i2c_isr(struct solo_dev *solo_dev) | |||
175 | 175 | ||
176 | solo_reg_write(solo_dev, SOLO_IRQ_STAT, SOLO_IRQ_IIC); | 176 | solo_reg_write(solo_dev, SOLO_IRQ_STAT, SOLO_IRQ_IIC); |
177 | 177 | ||
178 | if (status & (SOLO_IIC_STATE_TRNS & SOLO_IIC_STATE_SIG_ERR) || | 178 | if (status & (SOLO_IIC_STATE_TRNS | SOLO_IIC_STATE_SIG_ERR) || |
179 | solo_dev->i2c_id < 0) { | 179 | solo_dev->i2c_id < 0) { |
180 | solo_i2c_stop(solo_dev); | 180 | solo_i2c_stop(solo_dev); |
181 | return -ENXIO; | 181 | return -ENXIO; |
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index d38b3a8fb380..ef4cc9429c3a 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild | |||
@@ -382,6 +382,7 @@ header-y += usbdevice_fs.h | |||
382 | header-y += utime.h | 382 | header-y += utime.h |
383 | header-y += utsname.h | 383 | header-y += utsname.h |
384 | header-y += uvcvideo.h | 384 | header-y += uvcvideo.h |
385 | header-y += v4l2-common.h | ||
385 | header-y += v4l2-dv-timings.h | 386 | header-y += v4l2-dv-timings.h |
386 | header-y += v4l2-mediabus.h | 387 | header-y += v4l2-mediabus.h |
387 | header-y += v4l2-subdev.h | 388 | header-y += v4l2-subdev.h |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 195d8b3d9cfb..a121c012309a 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -68,6 +68,9 @@ extern int i2c_master_recv(const struct i2c_client *client, char *buf, | |||
68 | */ | 68 | */ |
69 | extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, | 69 | extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, |
70 | int num); | 70 | int num); |
71 | /* Unlocked flavor */ | ||
72 | extern int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, | ||
73 | int num); | ||
71 | 74 | ||
72 | /* This is the very generalized SMBus access routine. You probably do not | 75 | /* This is the very generalized SMBus access routine. You probably do not |
73 | want to use this, though; one of the functions below may be much easier, | 76 | want to use this, though; one of the functions below may be much easier, |
diff --git a/include/linux/uvcvideo.h b/include/linux/uvcvideo.h index f46a53f060d7..3b081862b9e8 100644 --- a/include/linux/uvcvideo.h +++ b/include/linux/uvcvideo.h | |||
@@ -58,7 +58,8 @@ struct uvc_xu_control_mapping { | |||
58 | struct uvc_xu_control_query { | 58 | struct uvc_xu_control_query { |
59 | __u8 unit; | 59 | __u8 unit; |
60 | __u8 selector; | 60 | __u8 selector; |
61 | __u8 query; | 61 | __u8 query; /* Video Class-Specific Request Code, */ |
62 | /* defined in linux/usb/video.h A.8. */ | ||
62 | __u16 size; | 63 | __u16 size; |
63 | __u8 __user *data; | 64 | __u8 __user *data; |
64 | }; | 65 | }; |
diff --git a/include/linux/v4l2-common.h b/include/linux/v4l2-common.h new file mode 100644 index 000000000000..0fa8b64c3cdb --- /dev/null +++ b/include/linux/v4l2-common.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * include/linux/v4l2-common.h | ||
3 | * | ||
4 | * Common V4L2 and V4L2 subdev definitions. | ||
5 | * | ||
6 | * Users are advised to #include this file either through videodev2.h | ||
7 | * (V4L2) or through v4l2-subdev.h (V4L2 subdev) rather than to refer | ||
8 | * to this file directly. | ||
9 | * | ||
10 | * Copyright (C) 2012 Nokia Corporation | ||
11 | * Contact: Sakari Ailus <sakari.ailus@iki.fi> | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * version 2 as published by the Free Software Foundation. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, but | ||
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
25 | * 02110-1301 USA | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | #ifndef __V4L2_COMMON__ | ||
30 | #define __V4L2_COMMON__ | ||
31 | |||
32 | /* | ||
33 | * | ||
34 | * Selection interface definitions | ||
35 | * | ||
36 | */ | ||
37 | |||
38 | /* Current cropping area */ | ||
39 | #define V4L2_SEL_TGT_CROP 0x0000 | ||
40 | /* Default cropping area */ | ||
41 | #define V4L2_SEL_TGT_CROP_DEFAULT 0x0001 | ||
42 | /* Cropping bounds */ | ||
43 | #define V4L2_SEL_TGT_CROP_BOUNDS 0x0002 | ||
44 | /* Current composing area */ | ||
45 | #define V4L2_SEL_TGT_COMPOSE 0x0100 | ||
46 | /* Default composing area */ | ||
47 | #define V4L2_SEL_TGT_COMPOSE_DEFAULT 0x0101 | ||
48 | /* Composing bounds */ | ||
49 | #define V4L2_SEL_TGT_COMPOSE_BOUNDS 0x0102 | ||
50 | /* Current composing area plus all padding pixels */ | ||
51 | #define V4L2_SEL_TGT_COMPOSE_PADDED 0x0103 | ||
52 | |||
53 | /* Backward compatibility target definitions --- to be removed. */ | ||
54 | #define V4L2_SEL_TGT_CROP_ACTIVE V4L2_SEL_TGT_CROP | ||
55 | #define V4L2_SEL_TGT_COMPOSE_ACTIVE V4L2_SEL_TGT_COMPOSE | ||
56 | #define V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL \ | ||
57 | V4L2_SEL_TGT_CROP | ||
58 | #define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL \ | ||
59 | V4L2_SEL_TGT_COMPOSE | ||
60 | |||
61 | /* Selection flags */ | ||
62 | #define V4L2_SEL_FLAG_GE (1 << 0) | ||
63 | #define V4L2_SEL_FLAG_LE (1 << 1) | ||
64 | #define V4L2_SEL_FLAG_KEEP_CONFIG (1 << 2) | ||
65 | |||
66 | /* Backward compatibility flag definitions --- to be removed. */ | ||
67 | #define V4L2_SUBDEV_SEL_FLAG_SIZE_GE V4L2_SEL_FLAG_GE | ||
68 | #define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE | ||
69 | #define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG | ||
70 | |||
71 | #endif /* __V4L2_COMMON__ */ | ||
diff --git a/include/linux/v4l2-subdev.h b/include/linux/v4l2-subdev.h index 812019ee1e06..8c57ee9872bb 100644 --- a/include/linux/v4l2-subdev.h +++ b/include/linux/v4l2-subdev.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/ioctl.h> | 26 | #include <linux/ioctl.h> |
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/v4l2-common.h> | ||
28 | #include <linux/v4l2-mediabus.h> | 29 | #include <linux/v4l2-mediabus.h> |
29 | 30 | ||
30 | /** | 31 | /** |
@@ -123,27 +124,14 @@ struct v4l2_subdev_frame_interval_enum { | |||
123 | __u32 reserved[9]; | 124 | __u32 reserved[9]; |
124 | }; | 125 | }; |
125 | 126 | ||
126 | #define V4L2_SUBDEV_SEL_FLAG_SIZE_GE (1 << 0) | ||
127 | #define V4L2_SUBDEV_SEL_FLAG_SIZE_LE (1 << 1) | ||
128 | #define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG (1 << 2) | ||
129 | |||
130 | /* active cropping area */ | ||
131 | #define V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL 0x0000 | ||
132 | /* cropping bounds */ | ||
133 | #define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS 0x0002 | ||
134 | /* current composing area */ | ||
135 | #define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL 0x0100 | ||
136 | /* composing bounds */ | ||
137 | #define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS 0x0102 | ||
138 | |||
139 | |||
140 | /** | 127 | /** |
141 | * struct v4l2_subdev_selection - selection info | 128 | * struct v4l2_subdev_selection - selection info |
142 | * | 129 | * |
143 | * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY | 130 | * @which: either V4L2_SUBDEV_FORMAT_ACTIVE or V4L2_SUBDEV_FORMAT_TRY |
144 | * @pad: pad number, as reported by the media API | 131 | * @pad: pad number, as reported by the media API |
145 | * @target: selection target, used to choose one of possible rectangles | 132 | * @target: Selection target, used to choose one of possible rectangles, |
146 | * @flags: constraint flags | 133 | * defined in v4l2-common.h; V4L2_SEL_TGT_* . |
134 | * @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*. | ||
147 | * @r: coordinates of the selection window | 135 | * @r: coordinates of the selection window |
148 | * @reserved: for future use, set to zero for now | 136 | * @reserved: for future use, set to zero for now |
149 | * | 137 | * |
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 2039c5d3292e..5d78910f926c 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
@@ -64,6 +64,7 @@ | |||
64 | #include <linux/compiler.h> | 64 | #include <linux/compiler.h> |
65 | #include <linux/ioctl.h> | 65 | #include <linux/ioctl.h> |
66 | #include <linux/types.h> | 66 | #include <linux/types.h> |
67 | #include <linux/v4l2-common.h> | ||
67 | 68 | ||
68 | /* | 69 | /* |
69 | * Common stuff for both V4L1 and V4L2 | 70 | * Common stuff for both V4L1 and V4L2 |
@@ -657,7 +658,7 @@ struct v4l2_buffer { | |||
657 | struct v4l2_plane *planes; | 658 | struct v4l2_plane *planes; |
658 | } m; | 659 | } m; |
659 | __u32 length; | 660 | __u32 length; |
660 | __u32 input; | 661 | __u32 reserved2; |
661 | __u32 reserved; | 662 | __u32 reserved; |
662 | }; | 663 | }; |
663 | 664 | ||
@@ -671,7 +672,6 @@ struct v4l2_buffer { | |||
671 | /* Buffer is ready, but the data contained within is corrupted. */ | 672 | /* Buffer is ready, but the data contained within is corrupted. */ |
672 | #define V4L2_BUF_FLAG_ERROR 0x0040 | 673 | #define V4L2_BUF_FLAG_ERROR 0x0040 |
673 | #define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ | 674 | #define V4L2_BUF_FLAG_TIMECODE 0x0100 /* timecode field is valid */ |
674 | #define V4L2_BUF_FLAG_INPUT 0x0200 /* input field is valid */ | ||
675 | #define V4L2_BUF_FLAG_PREPARED 0x0400 /* Buffer is prepared for queuing */ | 675 | #define V4L2_BUF_FLAG_PREPARED 0x0400 /* Buffer is prepared for queuing */ |
676 | /* Cache handling flags */ | 676 | /* Cache handling flags */ |
677 | #define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x0800 | 677 | #define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x0800 |
@@ -761,32 +761,12 @@ struct v4l2_crop { | |||
761 | struct v4l2_rect c; | 761 | struct v4l2_rect c; |
762 | }; | 762 | }; |
763 | 763 | ||
764 | /* Hints for adjustments of selection rectangle */ | ||
765 | #define V4L2_SEL_FLAG_GE 0x00000001 | ||
766 | #define V4L2_SEL_FLAG_LE 0x00000002 | ||
767 | |||
768 | /* Selection targets */ | ||
769 | |||
770 | /* Current cropping area */ | ||
771 | #define V4L2_SEL_TGT_CROP_ACTIVE 0x0000 | ||
772 | /* Default cropping area */ | ||
773 | #define V4L2_SEL_TGT_CROP_DEFAULT 0x0001 | ||
774 | /* Cropping bounds */ | ||
775 | #define V4L2_SEL_TGT_CROP_BOUNDS 0x0002 | ||
776 | /* Current composing area */ | ||
777 | #define V4L2_SEL_TGT_COMPOSE_ACTIVE 0x0100 | ||
778 | /* Default composing area */ | ||
779 | #define V4L2_SEL_TGT_COMPOSE_DEFAULT 0x0101 | ||
780 | /* Composing bounds */ | ||
781 | #define V4L2_SEL_TGT_COMPOSE_BOUNDS 0x0102 | ||
782 | /* Current composing area plus all padding pixels */ | ||
783 | #define V4L2_SEL_TGT_COMPOSE_PADDED 0x0103 | ||
784 | |||
785 | /** | 764 | /** |
786 | * struct v4l2_selection - selection info | 765 | * struct v4l2_selection - selection info |
787 | * @type: buffer type (do not use *_MPLANE types) | 766 | * @type: buffer type (do not use *_MPLANE types) |
788 | * @target: selection target, used to choose one of possible rectangles | 767 | * @target: Selection target, used to choose one of possible rectangles; |
789 | * @flags: constraints flags | 768 | * defined in v4l2-common.h; V4L2_SEL_TGT_* . |
769 | * @flags: constraints flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*. | ||
790 | * @r: coordinates of selection window | 770 | * @r: coordinates of selection window |
791 | * @reserved: for future use, rounds structure size to 64 bytes, set to zero | 771 | * @reserved: for future use, rounds structure size to 64 bytes, set to zero |
792 | * | 772 | * |
@@ -2039,6 +2019,8 @@ struct v4l2_modulator { | |||
2039 | /* Flags for the 'capability' field */ | 2019 | /* Flags for the 'capability' field */ |
2040 | #define V4L2_TUNER_CAP_LOW 0x0001 | 2020 | #define V4L2_TUNER_CAP_LOW 0x0001 |
2041 | #define V4L2_TUNER_CAP_NORM 0x0002 | 2021 | #define V4L2_TUNER_CAP_NORM 0x0002 |
2022 | #define V4L2_TUNER_CAP_HWSEEK_BOUNDED 0x0004 | ||
2023 | #define V4L2_TUNER_CAP_HWSEEK_WRAP 0x0008 | ||
2042 | #define V4L2_TUNER_CAP_STEREO 0x0010 | 2024 | #define V4L2_TUNER_CAP_STEREO 0x0010 |
2043 | #define V4L2_TUNER_CAP_LANG2 0x0020 | 2025 | #define V4L2_TUNER_CAP_LANG2 0x0020 |
2044 | #define V4L2_TUNER_CAP_SAP 0x0020 | 2026 | #define V4L2_TUNER_CAP_SAP 0x0020 |
diff --git a/include/media/adv7393.h b/include/media/adv7393.h new file mode 100644 index 000000000000..b28edf351842 --- /dev/null +++ b/include/media/adv7393.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * ADV7393 header file | ||
3 | * | ||
4 | * Copyright (C) 2010-2012 ADVANSEE - http://www.advansee.com/ | ||
5 | * Benoît Thébaudeau <benoit.thebaudeau@advansee.com> | ||
6 | * | ||
7 | * Based on ADV7343 driver, | ||
8 | * | ||
9 | * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License as | ||
13 | * published by the Free Software Foundation version 2. | ||
14 | * | ||
15 | * This program is distributed .as is. WITHOUT ANY WARRANTY of any | ||
16 | * kind, whether express or implied; without even the implied warranty | ||
17 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | */ | ||
20 | |||
21 | #ifndef ADV7393_H | ||
22 | #define ADV7393_H | ||
23 | |||
24 | #define ADV7393_COMPOSITE_ID (0) | ||
25 | #define ADV7393_COMPONENT_ID (1) | ||
26 | #define ADV7393_SVIDEO_ID (2) | ||
27 | |||
28 | #endif /* End of #ifndef ADV7393_H */ | ||
diff --git a/include/media/gpio-ir-recv.h b/include/media/gpio-ir-recv.h index 67797bf5d432..0142736a59db 100644 --- a/include/media/gpio-ir-recv.h +++ b/include/media/gpio-ir-recv.h | |||
@@ -14,8 +14,10 @@ | |||
14 | #define __GPIO_IR_RECV_H__ | 14 | #define __GPIO_IR_RECV_H__ |
15 | 15 | ||
16 | struct gpio_ir_recv_platform_data { | 16 | struct gpio_ir_recv_platform_data { |
17 | int gpio_nr; | 17 | int gpio_nr; |
18 | bool active_low; | 18 | bool active_low; |
19 | u64 allowed_protos; | ||
20 | const char *map_name; | ||
19 | }; | 21 | }; |
20 | 22 | ||
21 | #endif /* __GPIO_IR_RECV_H__ */ | 23 | #endif /* __GPIO_IR_RECV_H__ */ |
diff --git a/include/media/mt9t001.h b/include/media/mt9t001.h index e839a78bb9c5..03fd63edd133 100644 --- a/include/media/mt9t001.h +++ b/include/media/mt9t001.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | struct mt9t001_platform_data { | 4 | struct mt9t001_platform_data { |
5 | unsigned int clk_pol:1; | 5 | unsigned int clk_pol:1; |
6 | unsigned int ext_clk; | ||
6 | }; | 7 | }; |
7 | 8 | ||
8 | #endif | 9 | #endif |
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h index 7395c815939d..58f914a40b20 100644 --- a/include/media/v4l2-chip-ident.h +++ b/include/media/v4l2-chip-ident.h | |||
@@ -180,6 +180,9 @@ enum { | |||
180 | /* module adv7343: just ident 7343 */ | 180 | /* module adv7343: just ident 7343 */ |
181 | V4L2_IDENT_ADV7343 = 7343, | 181 | V4L2_IDENT_ADV7343 = 7343, |
182 | 182 | ||
183 | /* module adv7393: just ident 7393 */ | ||
184 | V4L2_IDENT_ADV7393 = 7393, | ||
185 | |||
183 | /* module saa7706h: just ident 7706 */ | 186 | /* module saa7706h: just ident 7706 */ |
184 | V4L2_IDENT_SAA7706H = 7706, | 187 | V4L2_IDENT_SAA7706H = 7706, |
185 | 188 | ||
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index a056e6ee1b68..5c416cdc88d5 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
@@ -100,6 +100,9 @@ struct video_device | |||
100 | /* Control handler associated with this device node. May be NULL. */ | 100 | /* Control handler associated with this device node. May be NULL. */ |
101 | struct v4l2_ctrl_handler *ctrl_handler; | 101 | struct v4l2_ctrl_handler *ctrl_handler; |
102 | 102 | ||
103 | /* vb2_queue associated with this device node. May be NULL. */ | ||
104 | struct vb2_queue *queue; | ||
105 | |||
103 | /* Priority state. If NULL, then v4l2_dev->prio will be used. */ | 106 | /* Priority state. If NULL, then v4l2_dev->prio will be used. */ |
104 | struct v4l2_prio_state *prio; | 107 | struct v4l2_prio_state *prio; |
105 | 108 | ||
diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h index d8b76f7392f8..19e93523c2d8 100644 --- a/include/media/v4l2-ioctl.h +++ b/include/media/v4l2-ioctl.h | |||
@@ -295,28 +295,19 @@ struct v4l2_ioctl_ops { | |||
295 | #define V4L2_DEBUG_IOCTL 0x01 | 295 | #define V4L2_DEBUG_IOCTL 0x01 |
296 | #define V4L2_DEBUG_IOCTL_ARG 0x02 | 296 | #define V4L2_DEBUG_IOCTL_ARG 0x02 |
297 | 297 | ||
298 | /* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */ | ||
299 | #define v4l_print_ioctl(name, cmd) \ | ||
300 | do { \ | ||
301 | printk(KERN_DEBUG "%s: ", name); \ | ||
302 | v4l_printk_ioctl(cmd); \ | ||
303 | } while (0) | ||
304 | |||
305 | /* Use this macro in I2C drivers where 'client' is the struct i2c_client | ||
306 | pointer */ | ||
307 | #define v4l_i2c_print_ioctl(client, cmd) \ | ||
308 | do { \ | ||
309 | v4l_client_printk(KERN_DEBUG, client, ""); \ | ||
310 | v4l_printk_ioctl(cmd); \ | ||
311 | } while (0) | ||
312 | |||
313 | /* Video standard functions */ | 298 | /* Video standard functions */ |
314 | extern const char *v4l2_norm_to_name(v4l2_std_id id); | 299 | extern const char *v4l2_norm_to_name(v4l2_std_id id); |
315 | extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod); | 300 | extern void v4l2_video_std_frame_period(int id, struct v4l2_fract *frameperiod); |
316 | extern int v4l2_video_std_construct(struct v4l2_standard *vs, | 301 | extern int v4l2_video_std_construct(struct v4l2_standard *vs, |
317 | int id, const char *name); | 302 | int id, const char *name); |
318 | /* Prints the ioctl in a human-readable format */ | 303 | /* Prints the ioctl in a human-readable format. If prefix != NULL, |
319 | extern void v4l_printk_ioctl(unsigned int cmd); | 304 | then do printk(KERN_DEBUG "%s: ", prefix) first. */ |
305 | extern void v4l_printk_ioctl(const char *prefix, unsigned int cmd); | ||
306 | |||
307 | /* Internal use only: get the mutex (if any) that we need to lock for the | ||
308 | given command. */ | ||
309 | struct video_device; | ||
310 | extern struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned cmd); | ||
320 | 311 | ||
321 | /* names for fancy debug output */ | 312 | /* names for fancy debug output */ |
322 | extern const char *v4l2_field_names[]; | 313 | extern const char *v4l2_field_names[]; |
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h index 90ed895e217d..8c6e825940e5 100644 --- a/include/media/videobuf-core.h +++ b/include/media/videobuf-core.h | |||
@@ -72,7 +72,6 @@ struct videobuf_buffer { | |||
72 | unsigned int height; | 72 | unsigned int height; |
73 | unsigned int bytesperline; /* use only if != 0 */ | 73 | unsigned int bytesperline; /* use only if != 0 */ |
74 | unsigned long size; | 74 | unsigned long size; |
75 | unsigned int input; | ||
76 | enum v4l2_field field; | 75 | enum v4l2_field field; |
77 | enum videobuf_state state; | 76 | enum videobuf_state state; |
78 | struct list_head stream; /* QBUF/DQBUF list */ | 77 | struct list_head stream; /* QBUF/DQBUF list */ |
@@ -142,7 +141,6 @@ struct videobuf_queue { | |||
142 | wait_queue_head_t wait; /* wait if queue is empty */ | 141 | wait_queue_head_t wait; /* wait if queue is empty */ |
143 | 142 | ||
144 | enum v4l2_buf_type type; | 143 | enum v4l2_buf_type type; |
145 | unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */ | ||
146 | unsigned int msize; | 144 | unsigned int msize; |
147 | enum v4l2_field field; | 145 | enum v4l2_field field; |
148 | enum v4l2_field last; /* for field=V4L2_FIELD_ALTERNATE */ | 146 | enum v4l2_field last; /* for field=V4L2_FIELD_ALTERNATE */ |
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index a15d1f1b319e..8dd9b6cc296b 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h | |||
@@ -244,12 +244,23 @@ struct vb2_ops { | |||
244 | void (*buf_queue)(struct vb2_buffer *vb); | 244 | void (*buf_queue)(struct vb2_buffer *vb); |
245 | }; | 245 | }; |
246 | 246 | ||
247 | struct v4l2_fh; | ||
248 | |||
247 | /** | 249 | /** |
248 | * struct vb2_queue - a videobuf queue | 250 | * struct vb2_queue - a videobuf queue |
249 | * | 251 | * |
250 | * @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h | 252 | * @type: queue type (see V4L2_BUF_TYPE_* in linux/videodev2.h |
251 | * @io_modes: supported io methods (see vb2_io_modes enum) | 253 | * @io_modes: supported io methods (see vb2_io_modes enum) |
252 | * @io_flags: additional io flags (see vb2_fileio_flags enum) | 254 | * @io_flags: additional io flags (see vb2_fileio_flags enum) |
255 | * @lock: pointer to a mutex that protects the vb2_queue struct. The | ||
256 | * driver can set this to a mutex to let the v4l2 core serialize | ||
257 | * the queuing ioctls. If the driver wants to handle locking | ||
258 | * itself, then this should be set to NULL. This lock is not used | ||
259 | * by the videobuf2 core API. | ||
260 | * @owner: The filehandle that 'owns' the buffers, i.e. the filehandle | ||
261 | * that called reqbufs, create_buffers or started fileio. | ||
262 | * This field is not used by the videobuf2 core API, but it allows | ||
263 | * drivers to easily associate an owner filehandle with the queue. | ||
253 | * @ops: driver-specific callbacks | 264 | * @ops: driver-specific callbacks |
254 | * @mem_ops: memory allocator specific callbacks | 265 | * @mem_ops: memory allocator specific callbacks |
255 | * @drv_priv: driver private data | 266 | * @drv_priv: driver private data |
@@ -273,6 +284,8 @@ struct vb2_queue { | |||
273 | enum v4l2_buf_type type; | 284 | enum v4l2_buf_type type; |
274 | unsigned int io_modes; | 285 | unsigned int io_modes; |
275 | unsigned int io_flags; | 286 | unsigned int io_flags; |
287 | struct mutex *lock; | ||
288 | struct v4l2_fh *owner; | ||
276 | 289 | ||
277 | const struct vb2_ops *ops; | 290 | const struct vb2_ops *ops; |
278 | const struct vb2_mem_ops *mem_ops; | 291 | const struct vb2_mem_ops *mem_ops; |
@@ -404,4 +417,45 @@ vb2_plane_size(struct vb2_buffer *vb, unsigned int plane_no) | |||
404 | return 0; | 417 | return 0; |
405 | } | 418 | } |
406 | 419 | ||
420 | /* | ||
421 | * The following functions are not part of the vb2 core API, but are simple | ||
422 | * helper functions that you can use in your struct v4l2_file_operations, | ||
423 | * struct v4l2_ioctl_ops and struct vb2_ops. They will serialize if vb2_queue->lock | ||
424 | * or video_device->lock is set, and they will set and test vb2_queue->owner | ||
425 | * to check if the calling filehandle is permitted to do the queuing operation. | ||
426 | */ | ||
427 | |||
428 | /* struct v4l2_ioctl_ops helpers */ | ||
429 | |||
430 | int vb2_ioctl_reqbufs(struct file *file, void *priv, | ||
431 | struct v4l2_requestbuffers *p); | ||
432 | int vb2_ioctl_create_bufs(struct file *file, void *priv, | ||
433 | struct v4l2_create_buffers *p); | ||
434 | int vb2_ioctl_prepare_buf(struct file *file, void *priv, | ||
435 | struct v4l2_buffer *p); | ||
436 | int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p); | ||
437 | int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p); | ||
438 | int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p); | ||
439 | int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i); | ||
440 | int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i); | ||
441 | |||
442 | /* struct v4l2_file_operations helpers */ | ||
443 | |||
444 | int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma); | ||
445 | int vb2_fop_release(struct file *file); | ||
446 | ssize_t vb2_fop_write(struct file *file, char __user *buf, | ||
447 | size_t count, loff_t *ppos); | ||
448 | ssize_t vb2_fop_read(struct file *file, char __user *buf, | ||
449 | size_t count, loff_t *ppos); | ||
450 | unsigned int vb2_fop_poll(struct file *file, poll_table *wait); | ||
451 | #ifndef CONFIG_MMU | ||
452 | unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr, | ||
453 | unsigned long len, unsigned long pgoff, unsigned long flags); | ||
454 | #endif | ||
455 | |||
456 | /* struct vb2_ops helpers, only use if vq->lock is non-NULL. */ | ||
457 | |||
458 | void vb2_ops_wait_prepare(struct vb2_queue *vq); | ||
459 | void vb2_ops_wait_finish(struct vb2_queue *vq); | ||
460 | |||
407 | #endif /* _MEDIA_VIDEOBUF2_CORE_H */ | 461 | #endif /* _MEDIA_VIDEOBUF2_CORE_H */ |
diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h index 19ae1e350567..8197f87d6c61 100644 --- a/include/media/videobuf2-dma-contig.h +++ b/include/media/videobuf2-dma-contig.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * videobuf2-dma-coherent.h - DMA coherent memory allocator for videobuf2 | 2 | * videobuf2-dma-contig.h - DMA contig memory allocator for videobuf2 |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Samsung Electronics | 4 | * Copyright (C) 2010 Samsung Electronics |
5 | * | 5 | * |
@@ -10,8 +10,8 @@ | |||
10 | * the Free Software Foundation. | 10 | * the Free Software Foundation. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #ifndef _MEDIA_VIDEOBUF2_DMA_COHERENT_H | 13 | #ifndef _MEDIA_VIDEOBUF2_DMA_CONTIG_H |
14 | #define _MEDIA_VIDEOBUF2_DMA_COHERENT_H | 14 | #define _MEDIA_VIDEOBUF2_DMA_CONTIG_H |
15 | 15 | ||
16 | #include <media/videobuf2-core.h> | 16 | #include <media/videobuf2-core.h> |
17 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c index 7eca25fae413..b29b88f93c9e 100644 --- a/sound/i2c/other/tea575x-tuner.c +++ b/sound/i2c/other/tea575x-tuner.c | |||
@@ -197,6 +197,8 @@ static int vidioc_g_tuner(struct file *file, void *priv, | |||
197 | strcpy(v->name, "FM"); | 197 | strcpy(v->name, "FM"); |
198 | v->type = V4L2_TUNER_RADIO; | 198 | v->type = V4L2_TUNER_RADIO; |
199 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; | 199 | v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; |
200 | if (!tea->cannot_read_data) | ||
201 | v->capability |= V4L2_TUNER_CAP_HWSEEK_BOUNDED; | ||
200 | v->rangelow = FREQ_LO; | 202 | v->rangelow = FREQ_LO; |
201 | v->rangehigh = FREQ_HI; | 203 | v->rangehigh = FREQ_HI; |
202 | v->rxsubchans = tea->stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; | 204 | v->rxsubchans = tea->stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; |
@@ -305,7 +307,7 @@ static int vidioc_s_hw_freq_seek(struct file *file, void *fh, | |||
305 | } | 307 | } |
306 | tea->val &= ~TEA575X_BIT_SEARCH; | 308 | tea->val &= ~TEA575X_BIT_SEARCH; |
307 | snd_tea575x_set_freq(tea); | 309 | snd_tea575x_set_freq(tea); |
308 | return -EAGAIN; | 310 | return -ENODATA; |
309 | } | 311 | } |
310 | 312 | ||
311 | static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl) | 313 | static int tea575x_s_ctrl(struct v4l2_ctrl *ctrl) |