aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx18/cx18-driver.h
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2009-01-30 22:33:02 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:38 -0400
commit302df9702192a68578916ef922c33370cbba350d (patch)
treeeab3173a4b82ec26c89b82c50e9bfb0fe2477953 /drivers/media/video/cx18/cx18-driver.h
parent4325dff220918c2ced82d16c3475d9a5afb1cab3 (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-driver.h')
-rw-r--r--drivers/media/video/cx18/cx18-driver.h142
1 files changed, 102 insertions, 40 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index d95c6ace2b96..a41d9c4178f0 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -319,59 +319,121 @@ struct cx18_open_id {
319/* forward declaration of struct defined in cx18-cards.h */ 319/* forward declaration of struct defined in cx18-cards.h */
320struct cx18_card; 320struct cx18_card;
321 321
322/*
323 * A note about "sliced" VBI data as implemented in this driver:
324 *
325 * Currently we collect the sliced VBI in the form of Ancillary Data
326 * packets, inserted by the AV core decoder/digitizer/slicer in the
327 * horizontal blanking region of the VBI lines, in "raw" mode as far as
328 * the Encoder is concerned. We don't ever tell the Encoder itself
329 * to provide sliced VBI. (AV Core: sliced mode - Encoder: raw mode)
330 *
331 * We then process the ancillary data ourselves to send the sliced data
332 * to the user application directly or build up MPEG-2 private stream 1
333 * packets to splice into (only!) MPEG-2 PS streams for the user app.
334 *
335 * (That's how ivtv essentially does it.)
336 *
337 * The Encoder should be able to extract certain sliced VBI data for
338 * us and provide it in a separate stream or splice it into any type of
339 * MPEG PS or TS stream, but this isn't implemented yet.
340 */
341
342/*
343 * Number of "raw" VBI samples per horizontal line we tell the Encoder to
344 * grab from the decoder/digitizer/slicer output for raw or sliced VBI.
345 * It depends on the pixel clock and the horiz rate:
346 *
347 * (1/Fh)*(2*Fp) = Samples/line
348 * = 4 bytes EAV + Anc data in hblank + 4 bytes SAV + active samples
349 *
350 * Sliced VBI data is sent as ancillary data during horizontal blanking
351 * Raw VBI is sent as active video samples during vertcal blanking
352 *
353 * We use a BT.656 pxiel clock of 13.5 MHz and a BT.656 active line
354 * length of 720 pixels @ 4:2:2 sampling. Thus...
355 *
356 * For systems that use a 15.734 kHz horizontal rate, such as
357 * NTSC-M, PAL-M, PAL-60, and other 60 Hz/525 line systems, we have:
358 *
359 * (1/15.734 kHz) * 2 * 13.5 MHz = 1716 samples/line =
360 * 4 bytes SAV + 268 bytes anc data + 4 bytes SAV + 1440 active samples
361 *
362 * For systems that use a 15.625 kHz horizontal rate, such as
363 * PAL-B/G/H, PAL-I, SECAM-L and other 50 Hz/625 line systems, we have:
364 *
365 * (1/15.625 kHz) * 2 * 13.5 MHz = 1728 samples/line =
366 * 4 bytes SAV + 280 bytes anc data + 4 bytes SAV + 1440 active samples
367 */
368static const u32 vbi_active_samples = 1444; /* 4 byte SAV + 720 Y + 720 U/V */
369static const u32 vbi_hblank_samples_60Hz = 272; /* 4 byte EAV + 268 anc/fill */
370static const u32 vbi_hblank_samples_50Hz = 284; /* 4 byte EAV + 280 anc/fill */
322 371
323#define CX18_VBI_FRAMES 32 372#define CX18_VBI_FRAMES 32
324 373
325/* VBI data */
326struct vbi_info { 374struct vbi_info {
327 u32 enc_size; 375 /* Current state of v4l2 VBI settings for this device */
328 u32 frame;
329 u8 cc_data_odd[256];
330 u8 cc_data_even[256];
331 int cc_pos;
332 u8 cc_no_update;
333 u8 vps[5];
334 u8 vps_found;
335 int wss;
336 u8 wss_found;
337 u8 wss_no_update;
338 u32 raw_decoder_line_size;
339 u8 raw_decoder_sav_odd_field;
340 u8 raw_decoder_sav_even_field;
341 u32 sliced_decoder_line_size;
342 u8 sliced_decoder_sav_odd_field;
343 u8 sliced_decoder_sav_even_field;
344 struct v4l2_format in; 376 struct v4l2_format in;
345 /* convenience pointer to sliced struct in vbi_in union */ 377 struct v4l2_sliced_vbi_format *sliced_in; /* pointer to in.fmt.sliced */
346 struct v4l2_sliced_vbi_format *sliced_in; 378 u32 count; /* Count of VBI data lines: 60 Hz: 12 or 50 Hz: 18 */
347 u32 service_set_in; 379 u32 start[2]; /* First VBI data line per field: 10 & 273 or 6 & 318 */
348 int insert_mpeg;
349 380
350 /* Buffer for the maximum of 2 * 18 * packet_size sliced VBI lines. 381 u32 frame; /* Count of VBI buffers/frames received from Encoder */
351 One for /dev/vbi0 and one for /dev/vbi8 */
352 struct v4l2_sliced_vbi_data sliced_data[36];
353 382
354 /* Buffer for VBI data inserted into MPEG stream. 383 /*
355 The first byte is a dummy byte that's never used. 384 * Vars for creation and insertion of MPEG Private Stream 1 packets
356 The next 16 bytes contain the MPEG header for the VBI data, 385 * of sliced VBI data into an MPEG PS
357 the remainder is the actual VBI data. 386 */
358 The max size accepted by the MPEG VBI reinsertion turns out
359 to be 1552 bytes, which happens to be 4 + (1 + 42) * (2 * 18) bytes,
360 where 4 is a four byte header, 42 is the max sliced VBI payload, 1 is
361 a single line header byte and 2 * 18 is the number of VBI lines per frame.
362 387
363 However, it seems that the data must be 1K aligned, so we have to 388 /* Boolean: create and insert Private Stream 1 packets into the PS */
364 pad the data until the 1 or 2 K boundary. 389 int insert_mpeg;
390
391 /*
392 * Buffer for the maximum of 2 * 18 * packet_size sliced VBI lines.
393 * Used in cx18-vbi.c only for collecting sliced data, and as a source
394 * during conversion of sliced VBI data into MPEG Priv Stream 1 packets.
395 * We don't need to save state here, but the array may have been a bit
396 * too big (2304 bytes) to alloc from the stack.
397 */
398 struct v4l2_sliced_vbi_data sliced_data[36];
365 399
366 This pointer array will allocate 2049 bytes to store each VBI frame. */ 400 /*
401 * A ring buffer of driver-generated MPEG-2 PS
402 * Program Pack/Private Stream 1 packets for sliced VBI data insertion
403 * into the MPEG PS stream.
404 *
405 * In each sliced_mpeg_data[] buffer is:
406 * 16 byte MPEG-2 PS Program Pack Header
407 * 16 byte MPEG-2 Private Stream 1 PES Header
408 * 4 byte magic number: "itv0" or "ITV0"
409 * 4 byte first field line mask, if "itv0"
410 * 4 byte second field line mask, if "itv0"
411 * 36 lines, if "ITV0"; or <36 lines, if "itv0"; of sliced VBI data
412 *
413 * Each line in the payload is
414 * 1 byte line header derived from the SDID (WSS, CC, VPS, etc.)
415 * 42 bytes of line data
416 *
417 * That's a maximum 1552 bytes of payload in the Private Stream 1 packet
418 * which is the payload size a PVR-350 (CX23415) MPEG decoder will
419 * accept for VBI data. So, including the headers, it's a maximum 1584
420 * bytes total.
421 */
422#define CX18_SLICED_MPEG_DATA_MAXSZ 1584
423 /* copy_vbi_buf() needs 8 temp bytes on the end for the worst case */
424#define CX18_SLICED_MPEG_DATA_BUFSZ (CX18_SLICED_MPEG_DATA_MAXSZ+8)
367 u8 *sliced_mpeg_data[CX18_VBI_FRAMES]; 425 u8 *sliced_mpeg_data[CX18_VBI_FRAMES];
368 u32 sliced_mpeg_size[CX18_VBI_FRAMES]; 426 u32 sliced_mpeg_size[CX18_VBI_FRAMES];
369 struct cx18_buffer sliced_mpeg_buf; 427
428 /* Count of Program Pack/Program Stream 1 packets inserted into PS */
370 u32 inserted_frame; 429 u32 inserted_frame;
371 430
372 u32 start[2], count; 431 /*
373 u32 raw_size; 432 * A dummy driver stream transfer buffer with a copy of the next
374 u32 sliced_size; 433 * sliced_mpeg_data[] buffer for output to userland apps.
434 * Only used in cx18-fileops.c, but its state needs to persist at times.
435 */
436 struct cx18_buffer sliced_mpeg_buf;
375}; 437};
376 438
377/* Per cx23418, per I2C bus private algo callback data */ 439/* Per cx23418, per I2C bus private algo callback data */