diff options
author | Andy Walls <awalls@radix.net> | 2009-01-30 22:33:02 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:38 -0400 |
commit | 302df9702192a68578916ef922c33370cbba350d (patch) | |
tree | eab3173a4b82ec26c89b82c50e9bfb0fe2477953 /drivers/media/video/cx18/cx18-vbi.c | |
parent | 4325dff220918c2ced82d16c3475d9a5afb1cab3 (diff) |
V4L/DVB (10439): cx18: Clean-up and enable sliced VBI handling
Removed legacy ivtv state variables, added comments, and cleaned
up sliced VBI related code. Enabled sliced VBI.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx18/cx18-vbi.c')
-rw-r--r-- | drivers/media/video/cx18/cx18-vbi.c | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/drivers/media/video/cx18/cx18-vbi.c b/drivers/media/video/cx18/cx18-vbi.c index fb595bd548e8..38d26c42e4cb 100644 --- a/drivers/media/video/cx18/cx18-vbi.c +++ b/drivers/media/video/cx18/cx18-vbi.c | |||
@@ -27,6 +27,16 @@ | |||
27 | #include "cx18-queue.h" | 27 | #include "cx18-queue.h" |
28 | #include "cx18-av-core.h" | 28 | #include "cx18-av-core.h" |
29 | 29 | ||
30 | /* | ||
31 | * Raster Reference/Protection (RP) bytes, used in Start/End Active | ||
32 | * Video codes emitted from the digitzer in VIP 1.x mode, that flag the start | ||
33 | * of VBI sample or VBI ancilliary data regions in the digitial ratser line. | ||
34 | * | ||
35 | * Task FieldEven VerticalBlank HorizontalBlank 0 0 0 0 | ||
36 | */ | ||
37 | static const u8 raw_vbi_sav_rp[2] = { 0x20, 0x60 }; /* __V_, _FV_ */ | ||
38 | static const u8 sliced_vbi_eav_rp[2] = { 0xb0, 0xf0 }; /* T_VH, TFVH */ | ||
39 | |||
30 | static void copy_vbi_data(struct cx18 *cx, int lines, u32 pts_stamp) | 40 | static void copy_vbi_data(struct cx18 *cx, int lines, u32 pts_stamp) |
31 | { | 41 | { |
32 | int line = 0; | 42 | int line = 0; |
@@ -34,10 +44,17 @@ static void copy_vbi_data(struct cx18 *cx, int lines, u32 pts_stamp) | |||
34 | u32 linemask[2] = { 0, 0 }; | 44 | u32 linemask[2] = { 0, 0 }; |
35 | unsigned short size; | 45 | unsigned short size; |
36 | static const u8 mpeg_hdr_data[] = { | 46 | static const u8 mpeg_hdr_data[] = { |
37 | 0x00, 0x00, 0x01, 0xba, 0x44, 0x00, 0x0c, 0x66, | 47 | /* MPEG-2 Program Pack */ |
38 | 0x24, 0x01, 0x01, 0xd1, 0xd3, 0xfa, 0xff, 0xff, | 48 | 0x00, 0x00, 0x01, 0xba, /* Prog Pack start code */ |
39 | 0x00, 0x00, 0x01, 0xbd, 0x00, 0x1a, 0x84, 0x80, | 49 | 0x44, 0x00, 0x0c, 0x66, 0x24, 0x01, /* SCR, SCR Ext, markers */ |
40 | 0x07, 0x21, 0x00, 0x5d, 0x63, 0xa7, 0xff, 0xff | 50 | 0x01, 0xd1, 0xd3, /* Mux Rate, markers */ |
51 | 0xfa, 0xff, 0xff, /* Res, Suff cnt, Stuff */ | ||
52 | /* MPEG-2 Private Stream 1 PES Packet */ | ||
53 | 0x00, 0x00, 0x01, 0xbd, /* Priv Stream 1 start */ | ||
54 | 0x00, 0x1a, /* length */ | ||
55 | 0x84, 0x80, 0x07, /* flags, hdr data len */ | ||
56 | 0x21, 0x00, 0x5d, 0x63, 0xa7, /* PTS, markers */ | ||
57 | 0xff, 0xff /* stuffing */ | ||
41 | }; | 58 | }; |
42 | const int sd = sizeof(mpeg_hdr_data); /* start of vbi data */ | 59 | const int sd = sizeof(mpeg_hdr_data); /* start of vbi data */ |
43 | int idx = cx->vbi.frame % CX18_VBI_FRAMES; | 60 | int idx = cx->vbi.frame % CX18_VBI_FRAMES; |
@@ -71,7 +88,7 @@ static void copy_vbi_data(struct cx18 *cx, int lines, u32 pts_stamp) | |||
71 | memcpy(dst + sd + 4, dst + sd + 12, line * 43); | 88 | memcpy(dst + sd + 4, dst + sd + 12, line * 43); |
72 | size = 4 + ((43 * line + 3) & ~3); | 89 | size = 4 + ((43 * line + 3) & ~3); |
73 | } else { | 90 | } else { |
74 | memcpy(dst + sd, "cx0", 4); | 91 | memcpy(dst + sd, "itv0", 4); |
75 | memcpy(dst + sd + 4, &linemask[0], 8); | 92 | memcpy(dst + sd + 4, &linemask[0], 8); |
76 | size = 12 + ((43 * line + 3) & ~3); | 93 | size = 12 + ((43 * line + 3) & ~3); |
77 | } | 94 | } |
@@ -90,10 +107,10 @@ static void copy_vbi_data(struct cx18 *cx, int lines, u32 pts_stamp) | |||
90 | Returns new compressed size. */ | 107 | Returns new compressed size. */ |
91 | static u32 compress_raw_buf(struct cx18 *cx, u8 *buf, u32 size) | 108 | static u32 compress_raw_buf(struct cx18 *cx, u8 *buf, u32 size) |
92 | { | 109 | { |
93 | u32 line_size = cx->vbi.raw_decoder_line_size; | 110 | u32 line_size = vbi_active_samples; |
94 | u32 lines = cx->vbi.count; | 111 | u32 lines = cx->vbi.count; |
95 | u8 sav1 = cx->vbi.raw_decoder_sav_odd_field; | 112 | u8 sav1 = raw_vbi_sav_rp[0]; |
96 | u8 sav2 = cx->vbi.raw_decoder_sav_even_field; | 113 | u8 sav2 = raw_vbi_sav_rp[1]; |
97 | u8 *q = buf; | 114 | u8 *q = buf; |
98 | u8 *p; | 115 | u8 *p; |
99 | int i; | 116 | int i; |
@@ -115,15 +132,16 @@ static u32 compress_raw_buf(struct cx18 *cx, u8 *buf, u32 size) | |||
115 | /* Compressed VBI format, all found sliced blocks put next to one another | 132 | /* Compressed VBI format, all found sliced blocks put next to one another |
116 | Returns new compressed size */ | 133 | Returns new compressed size */ |
117 | static u32 compress_sliced_buf(struct cx18 *cx, u32 line, u8 *buf, | 134 | static u32 compress_sliced_buf(struct cx18 *cx, u32 line, u8 *buf, |
118 | u32 size, u8 sav) | 135 | u32 size, u8 eav) |
119 | { | 136 | { |
120 | u32 line_size = cx->vbi.sliced_decoder_line_size; | ||
121 | struct v4l2_decode_vbi_line vbi; | 137 | struct v4l2_decode_vbi_line vbi; |
122 | int i; | 138 | int i; |
139 | u32 line_size = cx->is_60hz ? vbi_hblank_samples_60Hz | ||
140 | : vbi_hblank_samples_50Hz; | ||
123 | 141 | ||
124 | /* find the first valid line */ | 142 | /* find the first valid line */ |
125 | for (i = 0; i < size; i++, buf++) { | 143 | for (i = 0; i < size; i++, buf++) { |
126 | if (buf[0] == 0xff && !buf[1] && !buf[2] && buf[3] == sav) | 144 | if (buf[0] == 0xff && !buf[1] && !buf[2] && buf[3] == eav) |
127 | break; | 145 | break; |
128 | } | 146 | } |
129 | 147 | ||
@@ -133,8 +151,8 @@ static u32 compress_sliced_buf(struct cx18 *cx, u32 line, u8 *buf, | |||
133 | for (i = 0; i < size / line_size; i++) { | 151 | for (i = 0; i < size / line_size; i++) { |
134 | u8 *p = buf + i * line_size; | 152 | u8 *p = buf + i * line_size; |
135 | 153 | ||
136 | /* Look for SAV code */ | 154 | /* Look for EAV code */ |
137 | if (p[0] != 0xff || p[1] || p[2] || p[3] != sav) | 155 | if (p[0] != 0xff || p[1] || p[2] || p[3] != eav) |
138 | continue; | 156 | continue; |
139 | vbi.p = p + 4; | 157 | vbi.p = p + 4; |
140 | cx18_av_cmd(cx, VIDIOC_INT_DECODE_VBI_LINE, &vbi); | 158 | cx18_av_cmd(cx, VIDIOC_INT_DECODE_VBI_LINE, &vbi); |
@@ -159,6 +177,12 @@ void cx18_process_vbi_data(struct cx18 *cx, struct cx18_buffer *buf, | |||
159 | if (streamtype != CX18_ENC_STREAM_TYPE_VBI) | 177 | if (streamtype != CX18_ENC_STREAM_TYPE_VBI) |
160 | return; | 178 | return; |
161 | 179 | ||
180 | /* | ||
181 | * Note the CX23418 provides a 12 byte header, in it's raw VBI | ||
182 | * buffers to us, that we currently throw away: | ||
183 | * 0x3fffffff [4 bytes of something] [4 byte timestamp] | ||
184 | */ | ||
185 | |||
162 | /* Raw VBI data */ | 186 | /* Raw VBI data */ |
163 | if (cx18_raw_vbi(cx)) { | 187 | if (cx18_raw_vbi(cx)) { |
164 | u8 type; | 188 | u8 type; |
@@ -173,7 +197,7 @@ void cx18_process_vbi_data(struct cx18 *cx, struct cx18_buffer *buf, | |||
173 | size = buf->bytesused = compress_raw_buf(cx, p, size); | 197 | size = buf->bytesused = compress_raw_buf(cx, p, size); |
174 | 198 | ||
175 | /* second field of the frame? */ | 199 | /* second field of the frame? */ |
176 | if (type == cx->vbi.raw_decoder_sav_even_field) { | 200 | if (type == raw_vbi_sav_rp[1]) { |
177 | /* Dirty hack needed for backwards | 201 | /* Dirty hack needed for backwards |
178 | compatibility of old VBI software. */ | 202 | compatibility of old VBI software. */ |
179 | p += size - 4; | 203 | p += size - 4; |
@@ -187,14 +211,14 @@ void cx18_process_vbi_data(struct cx18 *cx, struct cx18_buffer *buf, | |||
187 | cx18_buf_swap(buf); | 211 | cx18_buf_swap(buf); |
188 | 212 | ||
189 | /* first field */ | 213 | /* first field */ |
190 | lines = compress_sliced_buf(cx, 0, p, size / 2, | 214 | /* compress_sliced_buf() will skip the 12 bytes of header */ |
191 | cx->vbi.sliced_decoder_sav_odd_field); | 215 | lines = compress_sliced_buf(cx, 0, p, size / 2, sliced_vbi_eav_rp[0]); |
192 | /* second field */ | 216 | /* second field */ |
193 | /* experimentation shows that the second half does not always | 217 | /* experimentation shows that the second half does not always |
194 | begin at the exact address. So start a bit earlier | 218 | begin at the exact address. So start a bit earlier |
195 | (hence 32). */ | 219 | (hence 32). */ |
196 | lines = compress_sliced_buf(cx, lines, p + size / 2 - 32, | 220 | lines = compress_sliced_buf(cx, lines, p + size / 2 - 32, |
197 | size / 2 + 32, cx->vbi.sliced_decoder_sav_even_field); | 221 | size / 2 + 32, sliced_vbi_eav_rp[1]); |
198 | /* always return at least one empty line */ | 222 | /* always return at least one empty line */ |
199 | if (lines == 0) { | 223 | if (lines == 0) { |
200 | cx->vbi.sliced_data[0].id = 0; | 224 | cx->vbi.sliced_data[0].id = 0; |