The patch number 9806 was added via Andy Walls <awa...@radix.net>
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:
        v4l-dvb-maintai...@linuxtv.org

------

From: Andy Walls  <awa...@radix.net>
cx18: Enable raw VBI capture


A combined authorship patch from Hans Verkuil and Andy Walls.  Raw
VBI can now be captured but requires a video capture to be in progress as well.

Priority: normal

Signed-off-by: Andy Walls <awa...@radix.net>
Signed-off-by: Hans Verkuil <hverk...@xs4all.nl>


---

 linux/drivers/media/video/cx18/cx18-cards.c   |    8 +-
 linux/drivers/media/video/cx18/cx18-cards.h   |    5 +
 linux/drivers/media/video/cx18/cx18-driver.c  |   49 +++++++++++++++---
 linux/drivers/media/video/cx18/cx18-fileops.c |    4 +
 linux/drivers/media/video/cx18/cx18-streams.c |    8 +-
 linux/drivers/media/video/cx18/cx18-vbi.c     |    3 +
 6 files changed, 59 insertions(+), 18 deletions(-)

diff -r 5b2e8f510c34 -r 46921026a875 linux/drivers/media/video/cx18/cx18-cards.c
--- a/linux/drivers/media/video/cx18/cx18-cards.c       Fri Dec 12 14:24:04 
2008 -0500
+++ b/linux/drivers/media/video/cx18/cx18-cards.c       Fri Dec 12 18:00:29 
2008 -0500
@@ -51,7 +51,7 @@ static const struct cx18_card cx18_card_
 static const struct cx18_card cx18_card_hvr1600_esmt = {
        .type = CX18_CARD_HVR_1600_ESMT,
        .name = "Hauppauge HVR-1600",
-       .comment = "VBI is not yet supported\n",
+       .comment = "Raw VBI supported; Sliced VBI is not yet supported\n",
        .v4l2_capabilities = CX18_CAP_ENCODER,
        .hw_audio_ctrl = CX18_HW_CX23418,
        .hw_muxer = CX18_HW_CS5345,
@@ -97,7 +97,7 @@ static const struct cx18_card cx18_card_
 static const struct cx18_card cx18_card_hvr1600_samsung = {
        .type = CX18_CARD_HVR_1600_SAMSUNG,
        .name = "Hauppauge HVR-1600 (Preproduction)",
-       .comment = "VBI is not yet supported\n",
+       .comment = "Raw VBI supported; Sliced VBI is not yet supported\n",
        .v4l2_capabilities = CX18_CAP_ENCODER,
        .hw_audio_ctrl = CX18_HW_CX23418,
        .hw_muxer = CX18_HW_CS5345,
@@ -152,7 +152,7 @@ static const struct cx18_card cx18_card_
 static const struct cx18_card cx18_card_h900 = {
        .type = CX18_CARD_COMPRO_H900,
        .name = "Compro VideoMate H900",
-       .comment = "VBI is not yet supported\n",
+       .comment = "Raw VBI supported; Sliced VBI is not yet supported\n",
        .v4l2_capabilities = CX18_CAP_ENCODER,
        .hw_audio_ctrl = CX18_HW_CX23418,
        .hw_all = CX18_HW_TUNER,
@@ -249,7 +249,7 @@ static const struct cx18_card cx18_card_
 static const struct cx18_card cx18_card_cnxt_raptor_pal = {
        .type = CX18_CARD_CNXT_RAPTOR_PAL,
        .name = "Conexant Raptor PAL/SECAM",
-       .comment = "VBI is not yet supported\n",
+       .comment = "Raw VBI supported; Sliced VBI is not yet supported\n",
        .v4l2_capabilities = CX18_CAP_ENCODER,
        .hw_audio_ctrl = CX18_HW_CX23418,
        .hw_muxer = CX18_HW_GPIO,
diff -r 5b2e8f510c34 -r 46921026a875 linux/drivers/media/video/cx18/cx18-cards.h
--- a/linux/drivers/media/video/cx18/cx18-cards.h       Fri Dec 12 14:24:04 
2008 -0500
+++ b/linux/drivers/media/video/cx18/cx18-cards.h       Fri Dec 12 18:00:29 
2008 -0500
@@ -48,8 +48,9 @@
 
 /* V4L2 capability aliases */
 #define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \
-                         V4L2_CAP_AUDIO | V4L2_CAP_READWRITE)
-/* | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE) not yet */
+                         V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | \
+                         V4L2_CAP_VBI_CAPTURE)
+/* | V4L2_CAP_SLICED_VBI_CAPTURE) not yet */
 
 struct cx18_card_video_input {
        u8  video_type;         /* video input type */
diff -r 5b2e8f510c34 -r 46921026a875 
linux/drivers/media/video/cx18/cx18-driver.c
--- a/linux/drivers/media/video/cx18/cx18-driver.c      Fri Dec 12 14:24:04 
2008 -0500
+++ b/linux/drivers/media/video/cx18/cx18-driver.c      Fri Dec 12 18:00:29 
2008 -0500
@@ -601,13 +601,47 @@ static int __devinit cx18_init_struct1(s
        /* VBI */
        cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
        cx->vbi.sliced_in = &cx->vbi.in.fmt.sliced;
-       cx->vbi.raw_size = 1456;
-       cx->vbi.raw_decoder_line_size = 1456;
-       cx->vbi.raw_decoder_sav_odd_field = 0x20;
-       cx->vbi.raw_decoder_sav_even_field = 0x60;
-       cx->vbi.sliced_decoder_line_size = 272;
-       cx->vbi.sliced_decoder_sav_odd_field = 0xB0;
-       cx->vbi.sliced_decoder_sav_even_field = 0xF0;
+
+       /*
+        * The VBI line sizes depend on the pixel clock and the horiz rate
+        *
+        * (1/Fh)*(2*Fp) = Samples/line
+        *     = 4 bytes EAV + Anc data in hblank + 4 bytes SAV + active samples
+        *
+        *  Sliced VBI is sent as ancillary data during horizontal blanking
+        *  Raw VBI is sent as active video samples during vertcal blanking
+        *
+        *  We use a  BT.656 pxiel clock of 13.5 MHz and a BT.656 active line
+        *  length of 720 pixels @ 4:2:2 sampling.  Thus...
+        *
+        *  For NTSC:
+        *
+        *  (1/15,734 kHz) * 2 * 13.5 MHz = 1716 samples/line =
+        *  4 bytes SAV + 268 bytes anc data + 4 bytes SAV + 1440 active samples
+        *
+        *  For PAL:
+        *
+        *  (1/15,625 kHz) * 2 * 13.5 MHz = 1728 samples/line =
+        *  4 bytes SAV + 280 bytes anc data + 4 bytes SAV + 1440 active samples
+        *
+        */
+
+       /* CX18-AV-Core number of VBI samples output per horizontal line */
+       cx->vbi.raw_decoder_line_size = 1444;   /* 4 byte SAV + 2 * 720 */
+       cx->vbi.sliced_decoder_line_size = 272; /* 60 Hz: 268+4, 50 Hz: 280+4 */
+
+       /* CX18-AV-Core VBI samples/line possibly rounded up */
+       cx->vbi.raw_size = 1444;   /* Real max size is 1444 */
+       cx->vbi.sliced_size = 284; /* Real max size is  284 */
+
+       /*
+        * CX18-AV-Core SAV/EAV RP codes in VIP 1.x mode
+        * Task Field VerticalBlank HorizontalBlank 0 0 0 0
+        */
+       cx->vbi.raw_decoder_sav_odd_field = 0x20;     /*   V  */
+       cx->vbi.raw_decoder_sav_even_field = 0x60;    /*  FV  */
+       cx->vbi.sliced_decoder_sav_odd_field = 0xB0;  /* T VH - actually EAV */
+       cx->vbi.sliced_decoder_sav_even_field = 0xF0; /* TFVH - actually EAV */
        return 0;
 }
 
@@ -640,6 +674,7 @@ static void __devinit cx18_init_struct2(
        cx->av_state.aud_input = CX18_AV_AUDIO8;
        cx->av_state.audclk_freq = 48000;
        cx->av_state.audmode = V4L2_TUNER_MODE_LANG1;
+       /* FIXME - 8 is NTSC value, investigate */
        cx->av_state.vbi_line_offset = 8;
 }
 
diff -r 5b2e8f510c34 -r 46921026a875 
linux/drivers/media/video/cx18/cx18-fileops.c
--- a/linux/drivers/media/video/cx18/cx18-fileops.c     Fri Dec 12 14:24:04 
2008 -0500
+++ b/linux/drivers/media/video/cx18/cx18-fileops.c     Fri Dec 12 18:00:29 
2008 -0500
@@ -223,7 +223,9 @@ static struct cx18_buffer *cx18_get_buff
                            !test_bit(CX18_F_S_APPL_IO, &s_vbi->s_flags)) {
                                while ((buf = cx18_dequeue(s_vbi, 
&s_vbi->q_full))) {
                                        /* byteswap and process VBI data */
-/*                                     cx18_process_vbi_data(cx, buf, 
s_vbi->dma_pts, s_vbi->type); */
+                                       cx18_process_vbi_data(cx, buf,
+                                                             s_vbi->dma_pts,
+                                                             s_vbi->type);
                                        cx18_stream_put_buf_fw(s_vbi, buf);
                                }
                        }
diff -r 5b2e8f510c34 -r 46921026a875 
linux/drivers/media/video/cx18/cx18-streams.c
--- a/linux/drivers/media/video/cx18/cx18-streams.c     Fri Dec 12 14:24:04 
2008 -0500
+++ b/linux/drivers/media/video/cx18/cx18-streams.c     Fri Dec 12 18:00:29 
2008 -0500
@@ -358,8 +358,7 @@ static void cx18_vbi_setup(struct cx18_s
        cx18_av_cmd(cx, VIDIOC_S_FMT, &cx->vbi.in);
 
        /* determine number of lines and total number of VBI bytes.
-          A raw line takes 1443 bytes: 2 * 720 + 4 byte frame header - 1
-          The '- 1' byte is probably an unused U or V byte. Or something...
+          A raw line takes 1444 bytes: 4 byte SAV code + 2 * 720
           A sliced line takes 51 bytes: 4 byte frame header, 4 byte internal
           header, 42 data bytes + checksum (to be confirmed) */
        if (raw) {
@@ -377,14 +376,15 @@ static void cx18_vbi_setup(struct cx18_s
        /* Lines per field */
        data[1] = (lines / 2) | ((lines / 2) << 16);
        /* bytes per line */
-       data[2] = (raw ? cx->vbi.raw_size : cx->vbi.sliced_size);
+       data[2] = (raw ? cx->vbi.raw_decoder_line_size
+                      : cx->vbi.sliced_decoder_line_size);
        /* Every X number of frames a VBI interrupt arrives
           (frames as in 25 or 30 fps) */
        data[3] = 1;
        /* Setup VBI for the cx25840 digitizer */
        if (raw) {
                data[4] = 0x20602060;
-               data[5] = 0x30703070;
+               data[5] = 0x307090d0;
        } else {
                data[4] = 0xB0F0B0F0;
                data[5] = 0xA0E0A0E0;
diff -r 5b2e8f510c34 -r 46921026a875 linux/drivers/media/video/cx18/cx18-vbi.c
--- a/linux/drivers/media/video/cx18/cx18-vbi.c Fri Dec 12 14:24:04 2008 -0500
+++ b/linux/drivers/media/video/cx18/cx18-vbi.c Fri Dec 12 18:00:29 2008 -0500
@@ -165,6 +165,9 @@ void cx18_process_vbi_data(struct cx18 *
 
                cx18_buf_swap(buf);
 
+               /* Skip 12 bytes of header that gets stuffed in */
+               size -= 12;
+               memcpy(p, &buf->buf[12], size);
                type = p[3];
 
                size = buf->bytesused = compress_raw_buf(cx, p, size);


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/46921026a875ca98d970071ff72307fc21ceee5a

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

Reply via email to