The patch number 10857 was added via Mauro Carvalho Chehab <mche...@redhat.com>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <linux-me...@vger.kernel.org>

------

From: Mauro Carvalho Chehab  <mche...@redhat.com>
merge: http://linuxtv.org/hg/~awalls/v4l-dvb


commit && make && hg push

Signed-off-by: Mauro Carvalho Chehab <mche...@redhat.com>


---

 linux/drivers/media/video/cx18/cx18-audio.c    |    1 
 linux/drivers/media/video/cx18/cx18-av-core.c  |   46 ++++++++++++-----
 linux/drivers/media/video/cx18/cx18-av-core.h  |   19 ++++---
 linux/drivers/media/video/cx18/cx18-av-vbi.c   |    6 +-
 linux/drivers/media/video/cx18/cx18-controls.c |   42 +++++++++++----
 linux/drivers/media/video/cx18/cx18-driver.c   |    3 -
 linux/drivers/media/video/cx18/cx18-streams.c  |    5 -
 linux/drivers/media/video/cx18/cx18-vbi.c      |    9 +--
 8 files changed, 89 insertions(+), 42 deletions(-)

diff -r 4f0dae5b5afb -r 4552dc2948e0 linux/drivers/media/video/cx18/cx18-audio.c
--- a/linux/drivers/media/video/cx18/cx18-audio.c       Mon Mar 09 00:49:16 
2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-audio.c       Mon Mar 09 00:54:19 
2009 -0300
@@ -24,6 +24,7 @@
 #include "cx18-driver.h"
 #include "cx18-io.h"
 #include "cx18-cards.h"
+#include "cx18-audio.h"
 
 #define CX18_AUDIO_ENABLE 0xc72014
 
diff -r 4f0dae5b5afb -r 4552dc2948e0 
linux/drivers/media/video/cx18/cx18-av-core.c
--- a/linux/drivers/media/video/cx18/cx18-av-core.c     Mon Mar 09 00:49:16 
2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-core.c     Mon Mar 09 00:54:19 
2009 -0300
@@ -292,23 +292,29 @@ void cx18_av_std_setup(struct cx18 *cx)
                 *
                 * vsync:     always 6 half-lines of vsync pulses
                 * vactive:   half lines of active video
-                * vblank656: half lines, after line 3, of blanked video
-                * vblank:    half lines, after line 9, of blanked video
+                * vblank656: half lines, after line 3/mid-266, of blanked video
+                * vblank:    half lines, after line 9/272, of blanked video
                 *
+                * As far as I can tell:
                 * vblank656 starts counting from the falling edge of the first
-                *      vsync pulse (start of line 4)
+                *      vsync pulse (start of line 4 or mid-266)
                 * vblank starts counting from the after the 6 vsync pulses and
-                *      6 equalization pulses (start of line 10)
+                *      6 or 5 equalization pulses (start of line 10 or 272)
                 *
                 * For 525 line systems the driver will extract VBI information
-                * from lines 10 through 21.  To avoid the EAV RP code from
-                * toggling at the start of hblank at line 22, where sliced VBI
-                * data from line 21 is stuffed, also treat line 22 as blanked.
+                * from lines 10-21 and lines 273-284.
                 */
-               vblank656 = 38; /* lines  4 through  22 */
-               vblank = 26;    /* lines 10 through  22 */
-               vactive = 481;  /* lines 23 through 262.5 */
-
+               vblank656 = 38; /* lines  4 -  22  &  266 - 284 */
+               vblank = 26;    /* lines 10 -  22  &  272 - 284 */
+               vactive = 481;  /* lines 23 - 263  &  285 - 525 */
+
+               /*
+                * For a 13.5 Mpps clock and 15,734.26 Hz line rate, a line is
+                * is 858 pixels = 720 active + 138 blanking.  The Hsync leading
+                * edge should happen 1.2 us * 13.5 Mpps ~= 16 pixels after the
+                * end of active video, leaving 122 pixels of hblank to ignore
+                * before active video starts.
+                */
                hactive = 720;
                hblank = 122;
                luma_lpf = 1;
@@ -867,8 +873,22 @@ static int cx18_av_s_fmt(struct v4l2_sub
                Hsrc = (cx18_av_read(cx, 0x472) & 0x3f) << 4;
                Hsrc |= (cx18_av_read(cx, 0x471) & 0xf0) >> 4;
 
-               Vlines = pix->height + (is_50Hz ? 4 : 7);
-
+               /*
+                * This adjustment reflects the excess of vactive, set in
+                * cx18_av_std_setup(), above standard values:
+                *
+                * 480 + 1 for 60 Hz systems
+                * 576 + 4 for 50 Hz systems
+                */
+               Vlines = pix->height + (is_50Hz ? 4 : 1);
+
+               /*
+                * Invalid height and width scaling requests are:
+                * 1. width less than 1/16 of the source width
+                * 2. width greater than the source width
+                * 3. height less than 1/8 of the source height
+                * 4. height greater than the source height
+                */
                if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) ||
                    (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {
                        CX18_ERR_DEV(sd, "%dx%d is not a valid size!\n",
diff -r 4f0dae5b5afb -r 4552dc2948e0 
linux/drivers/media/video/cx18/cx18-av-core.h
--- a/linux/drivers/media/video/cx18/cx18-av-core.h     Mon Mar 09 00:49:16 
2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-core.h     Mon Mar 09 00:54:19 
2009 -0300
@@ -89,16 +89,21 @@ struct cx18_av_state {
 
        /*
         * The VBI slicer starts operating and counting lines, begining at
-        * slicer line count of 1, at D lines after the deassertion of VRESET
-        * This staring field line, S, is 6 or 10 for 625 or 525 line systems.
-        * Sliced ancillary data captured on VBI slicer line M is sent at the
-        * beginning of the next VBI slicer line, VBI slicer line count N = M+1.
-        * Thus when the VBI slicer reports a VBI slicer line number with
-        * ancillary data, the IDID0 byte indicates VBI slicer line N.
-        * The actual field line that the captured data comes from is
+        * slicer line count of 1, at D lines after the deassertion of VRESET.
+        * This staring field line, S, is 6 (& 319) or 10 (& 273) for 625 or 525
+        * line systems respectively.  Sliced ancillary data captured on VBI
+        * slicer line M is inserted after the VBI slicer is done with line M,
+        * when VBI slicer line count is N = M+1.  Thus when the VBI slicer
+        * reports a VBI slicer line number with ancillary data, the IDID0 byte
+        * indicates VBI slicer line N.  The actual field line that the captured
+        * data comes from is
+        *
         * L = M+(S+D-1) = N-1+(S+D-1) = N + (S+D-2).
         *
+        * L is the line in the field, not frame, from which the VBI data came.
+        * N is the line reported by the slicer in the ancillary data.
         * D is the slicer_line_delay value programmed into register 0x47f.
+        * S is 6 for 625 line systems or 10 for 525 line systems
         * (S+D-2) is the slicer_line_offset used to convert slicer reported
         * line counts to actual field lines.
         */
diff -r 4f0dae5b5afb -r 4552dc2948e0 
linux/drivers/media/video/cx18/cx18-av-vbi.c
--- a/linux/drivers/media/video/cx18/cx18-av-vbi.c      Mon Mar 09 00:49:16 
2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-av-vbi.c      Mon Mar 09 00:54:19 
2009 -0300
@@ -142,7 +142,7 @@ int cx18_av_vbi(struct cx18 *cx, unsigne
                        0, V4L2_SLICED_TELETEXT_B, 0,   /* 1 */
                        0, V4L2_SLICED_WSS_625, 0,      /* 4 */
                        V4L2_SLICED_CAPTION_525,        /* 6 */
-                       V4L2_SLICED_VPS, 0, 0, 0, 0,    /* 7 - unlike cx25840 */
+                       0, 0, V4L2_SLICED_VPS, 0, 0,    /* 9 */
                        0, 0, 0, 0
                };
                int is_pal = !(state->std & V4L2_STD_525_60);
@@ -243,7 +243,7 @@ int cx18_av_vbi(struct cx18 *cx, unsigne
                                        lcr[i] |= 6 << (4 * x);
                                        break;
                                case V4L2_SLICED_VPS:
-                                       lcr[i] |= 7 << (4 * x); /*'840 differs*/
+                                       lcr[i] |= 9 << (4 * x);
                                        break;
                                }
                        }
@@ -301,7 +301,7 @@ int cx18_av_vbi(struct cx18 *cx, unsigne
                        sdid = V4L2_SLICED_CAPTION_525;
                        err = !odd_parity(p[0]) || !odd_parity(p[1]);
                        break;
-               case 7: /* Differs from cx25840 */
+               case 9:
                        sdid = V4L2_SLICED_VPS;
                        if (decode_vps(p, p) != 0)
                                err = 1;
diff -r 4f0dae5b5afb -r 4552dc2948e0 
linux/drivers/media/video/cx18/cx18-controls.c
--- a/linux/drivers/media/video/cx18/cx18-controls.c    Mon Mar 09 00:49:16 
2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-controls.c    Mon Mar 09 00:54:19 
2009 -0300
@@ -166,15 +166,26 @@ static int cx18_g_ctrl(struct cx18 *cx, 
        return 0;
 }
 
-static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt 
fmt)
+static int cx18_setup_vbi_fmt(struct cx18 *cx,
+                             enum v4l2_mpeg_stream_vbi_fmt fmt,
+                             enum v4l2_mpeg_stream_type type)
 {
        if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE))
                return -EINVAL;
        if (atomic_read(&cx->ana_capturing) > 0)
                return -EBUSY;
 
-       /* First try to allocate sliced VBI buffers if needed. */
-       if (fmt && cx->vbi.sliced_mpeg_data[0] == NULL) {
+       if (fmt != V4L2_MPEG_STREAM_VBI_FMT_IVTV ||
+           type != V4L2_MPEG_STREAM_TYPE_MPEG2_PS) {
+               /* We don't do VBI insertion aside from IVTV format in a PS */
+               cx->vbi.insert_mpeg = V4L2_MPEG_STREAM_VBI_FMT_NONE;
+               CX18_DEBUG_INFO("disabled insertion of sliced VBI data into "
+                               "the MPEG stream\n");
+               return 0;
+       }
+
+       /* Allocate sliced VBI buffers if needed. */
+       if (cx->vbi.sliced_mpeg_data[0] == NULL) {
                int i;
 
                for (i = 0; i < CX18_VBI_FRAMES; i++) {
@@ -185,19 +196,27 @@ static int cx18_setup_vbi_fmt(struct cx1
                                        kfree(cx->vbi.sliced_mpeg_data[i]);
                                        cx->vbi.sliced_mpeg_data[i] = NULL;
                                }
+                               cx->vbi.insert_mpeg =
+                                                 V4L2_MPEG_STREAM_VBI_FMT_NONE;
+                               CX18_WARN("Unable to allocate buffers for "
+                                         "sliced VBI data insertion\n");
                                return -ENOMEM;
                        }
                }
        }
 
        cx->vbi.insert_mpeg = fmt;
-
-       if (cx->vbi.insert_mpeg == 0)
-               return 0;
-       /* Need sliced data for mpeg insertion */
+       CX18_DEBUG_INFO("enabled insertion of sliced VBI data into the MPEG PS,"
+                       "when sliced VBI is enabled\n");
+
+       /*
+        * If our current settings have no lines set for capture, store a valid,
+        * default set of service lines to capture, in our current settings.
+        */
        if (cx18_get_service_set(cx->vbi.sliced_in) == 0) {
                if (cx->is_60hz)
-                       cx->vbi.sliced_in->service_set = 
V4L2_SLICED_CAPTION_525;
+                       cx->vbi.sliced_in->service_set =
+                                                       V4L2_SLICED_CAPTION_525;
                else
                        cx->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625;
                cx18_expand_service_set(cx->vbi.sliced_in, cx->is_50hz);
@@ -284,8 +303,11 @@ int cx18_s_ext_ctrls(struct file *file, 
                priv.cx = cx;
                priv.s = &cx->streams[id->type];
                err = cx2341x_update(&priv, cx18_api_func, &cx->params, &p);
-               if (!err && cx->params.stream_vbi_fmt != p.stream_vbi_fmt)
-                       err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt);
+               if (!err &&
+                   (cx->params.stream_vbi_fmt != p.stream_vbi_fmt ||
+                    cx->params.stream_type != p.stream_type))
+                       err = cx18_setup_vbi_fmt(cx, p.stream_vbi_fmt,
+                                                p.stream_type);
                cx->params = p;
                cx->dualwatch_stereo_mode = p.audio_properties & 0x0300;
                idx = p.audio_properties & 0x03;
diff -r 4f0dae5b5afb -r 4552dc2948e0 
linux/drivers/media/video/cx18/cx18-driver.c
--- a/linux/drivers/media/video/cx18/cx18-driver.c      Mon Mar 09 00:49:16 
2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-driver.c      Mon Mar 09 00:54:19 
2009 -0300
@@ -273,8 +273,7 @@ void cx18_read_eeprom(struct cx18 *cx, s
        u8 eedata[256];
 
        memset(&c, 0, sizeof(c));
-       strncpy(c.name, "cx18 tveeprom tmp", sizeof(c.name));
-       c.name[sizeof(c.name)-1] = '\0';
+       strlcpy(c.name, "cx18 tveeprom tmp", sizeof(c.name));
        c.adapter = &cx->i2c_adap[0];
        c.addr = 0xA0 >> 1;
 
diff -r 4f0dae5b5afb -r 4552dc2948e0 
linux/drivers/media/video/cx18/cx18-streams.c
--- a/linux/drivers/media/video/cx18/cx18-streams.c     Mon Mar 09 00:49:16 
2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-streams.c     Mon Mar 09 00:54:19 
2009 -0300
@@ -413,9 +413,8 @@ static void cx18_vbi_setup(struct cx18_s
                 * 0x90 (Task                         HorizontalBlank)
                 * 0xd0 (Task EvenField               HorizontalBlank)
                 *
-                * We have set the digitzer to consider the first active line
-                * as part of VerticalBlank as well so we don't have to look for
-                * these problem codes nor lose the last line of sliced data.
+                * We have set the digitzer such that we don't have to worry
+                * about these problem codes.
                 */
                data[4] = 0xB0F0B0F0;
                /*
diff -r 4f0dae5b5afb -r 4552dc2948e0 linux/drivers/media/video/cx18/cx18-vbi.c
--- a/linux/drivers/media/video/cx18/cx18-vbi.c Mon Mar 09 00:49:16 2009 -0300
+++ b/linux/drivers/media/video/cx18/cx18-vbi.c Mon Mar 09 00:54:19 2009 -0300
@@ -169,7 +169,7 @@ void cx18_process_vbi_data(struct cx18 *
                           int streamtype)
 {
        u8 *p = (u8 *) buf->buf;
-       u32 *q = (u32 *) buf->buf;
+       __be32 *q = (__be32 *) buf->buf;
        u32 size = buf->bytesused;
        u32 pts;
        int lines;
@@ -178,8 +178,9 @@ void cx18_process_vbi_data(struct cx18 *
                return;
 
        /*
-        * The CX23418 sends us data that is 32 bit LE swapped, but we want
-        * the raw VBI bytes in the order they were in the raster line
+        * The CX23418 sends us data that is 32 bit little-endian swapped,
+        * but we want the raw VBI bytes in the order they were in the raster
+        * line.  This has a side effect of making the 12 byte header big endian
         */
        cx18_buf_swap(buf);
 
@@ -218,7 +219,7 @@ void cx18_process_vbi_data(struct cx18 *
 
        /* Sliced VBI data with data insertion */
 
-       pts = (be32_to_cpu(q[0] == 0x3fffffff)) ? be32_to_cpu(q[2]) : 0;
+       pts = (be32_to_cpu(q[0]) == 0x3fffffff) ? be32_to_cpu(q[2]) : 0;
 
        /*
         * For calls to compress_sliced_buf(), ensure there are an integral


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/4552dc2948e08d50115368141e1bb6358034ba71

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to