Skip to contentSkip to conversation

vivid: add teletext support to VBI capture

PATCH New Hans Verkuil 1 participant 1 message Sep 20, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vivid: add teletext support to VBI capture

This is useful to test teletext capture applications like alevt and mtt.

It also fixes a previously undetected bug where the PAL VBI start line of the second field was off by one. Using the new field start defines helps a lot fixing such bugs.

---
 Documentation/video4linux/vivid.txt          | 10 ++--
 drivers/media/platform/vivid/vivid-vbi-cap.c | 43 +++++++++++-----
 drivers/media/platform/vivid/vivid-vbi-gen.c | 76 +++++++++++++++++++++++++++-
 drivers/media/platform/vivid/vivid-vbi-gen.h |  2 +-
 drivers/media/platform/vivid/vivid-vbi-out.c |  7 +--
 drivers/media/platform/vivid/vivid-vid-cap.c |  2 +-
 drivers/media/platform/vivid/vivid-vid-out.c |  2 +-
 7 files changed, 117 insertions(+), 25 deletions(-)
Documentation/video4linux/vivid.txt +6 -4
index 4f1d442..eeb11a2 100644
@@ -422,7 +422,7 @@ generate Closed Caption and XDS data. The closed caption stream will
 alternate between "Hello world!" and "Closed captions test" every second.
 The XDS stream will give the current time once a minute. For 50 Hz standards
 it will generate the Wide Screen Signal which is based on the actual Video
-Aspect Ratio control setting.
+Aspect Ratio control setting and teletext pages 100-159, one page per frame.
 
 The VBI device will only work for the S-Video and TV inputs, it will give
 back an error if the current input is a webcam or HDMI.
@@ -435,8 +435,8 @@ There are three types of VBI output devices: those that only support raw
 (undecoded) VBI, those that only support sliced (decoded) VBI and those that
 support both. This is determined by the node_types module option.
 
-The sliced VBI output supports the Wide Screen Signal for 50 Hz standards
-and Closed Captioning + XDS for 60 Hz standards.
+The sliced VBI output supports the Wide Screen Signal and the teletext signal
+for 50 Hz standards and Closed Captioning + XDS for 60 Hz standards.
 
 The VBI device will only work for the S-Video output, it will give
 back an error if the current output is HDMI.
@@ -910,7 +910,8 @@ capture device.
 
 For VBI looping to work all of the above must be valid and in addition the vbi
 output must be configured for sliced VBI. The VBI capture side can be configured
-for either raw or sliced VBI.
+for either raw or sliced VBI. Note that at the moment only CC/XDS (60 Hz formats)
+and WSS (50 Hz formats) VBI data is looped. Teletext VBI data is not looped.
 
 
 Section 10.2: Radio & RDS Looping
@@ -1090,6 +1091,7 @@ Just as a reminder and in no particular order:
 - Add virtual sub-devices and media controller support
 - Some support for testing compressed video
 - Add support to loop raw VBI output to raw VBI input
+- Add support to loop teletext sliced VBI output to VBI input
 - Fix sequence/field numbering when looping of video with alternate fields
 - Add support for V4L2_CID_BG_COLOR for video outputs
 - Add ARGB888 overlay support: better testing of the alpha channel
drivers/media/platform/vivid/vivid-vbi-cap.c +29 -14

96 lines not on this page · raw message

drivers/media/platform/vivid/vivid-vbi-gen.c +75 -1

110 lines not on this page · raw message

drivers/media/platform/vivid/vivid-vbi-gen.h +1 -1
index 401dd47..8444abe 100644
@@ -21,7 +21,7 @@
 #define _VIVID_VBI_GEN_H_
 
 struct vivid_vbi_gen_data {
-	struct v4l2_sliced_vbi_data data[2];
+	struct v4l2_sliced_vbi_data data[25];
 	u8 time_of_day_packet[16];
 };
 
drivers/media/platform/vivid/vivid-vbi-out.c +4 -3
index 039316d..9d00a07 100644
@@ -149,8 +149,8 @@ int vidioc_g_fmt_vbi_out(struct file *file, void *priv,
 	vbi->offset = 24;
 	vbi->samples_per_line = 1440;
 	vbi->sample_format = V4L2_PIX_FMT_GREY;
-	vbi->start[0] = is_60hz ? 10 : 6;
-	vbi->start[1] = is_60hz ? 273 : 318;
+	vbi->start[0] = is_60hz ? V4L2_VBI_ITU_525_F1_START + 9 : V4L2_VBI_ITU_625_F1_START + 5;
+	vbi->start[1] = is_60hz ? V4L2_VBI_ITU_525_F2_START + 9 : V4L2_VBI_ITU_625_F2_START + 5;
 	vbi->count[0] = vbi->count[1] = is_60hz ? 12 : 18;
 	vbi->flags = dev->vbi_cap_interlaced ? V4L2_VBI_INTERLACED : 0;
 	vbi->reserved[0] = 0;
@@ -195,7 +195,8 @@ int vidioc_try_fmt_sliced_vbi_out(struct file *file, void *fh, struct v4l2_forma
 	if (!vivid_is_svid_out(dev) || !dev->has_sliced_vbi_out)
 		return -EINVAL;
 
-	service_set &= is_60hz ? V4L2_SLICED_CAPTION_525 : V4L2_SLICED_WSS_625;
+	service_set &= is_60hz ? V4L2_SLICED_CAPTION_525 :
+				 V4L2_SLICED_WSS_625 | V4L2_SLICED_TELETEXT_B;
 	vivid_fill_service_lines(vbi, service_set);
 	return 0;
 }
drivers/media/platform/vivid/vivid-vid-cap.c +1 -1
index b016aed..331c544 100644
@@ -419,7 +419,7 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls)
 		} else {
 			dev->src_rect.height = 576;
 			dev->timeperframe_vid_cap = (struct v4l2_fract) { 1000, 25000 };
-			dev->service_set_cap = V4L2_SLICED_WSS_625;
+			dev->service_set_cap = V4L2_SLICED_WSS_625 | V4L2_SLICED_TELETEXT_B;
 		}
 		tpg_s_rgb_range(&dev->tpg, V4L2_DV_RGB_RANGE_AUTO);
 		break;
drivers/media/platform/vivid/vivid-vid-out.c +1 -1
index d0e0e95..69c2dbd 100644
@@ -234,7 +234,7 @@ void vivid_update_format_out(struct vivid_dev *dev)
 		} else {
 			dev->sink_rect.height = 576;
 			dev->timeperframe_vid_out = (struct v4l2_fract) { 1000, 25000 };
-			dev->service_set_out = V4L2_SLICED_WSS_625;
+			dev->service_set_out = V4L2_SLICED_WSS_625 | V4L2_SLICED_TELETEXT_B;
 		}
 		dev->colorspace_out = V4L2_COLORSPACE_SMPTE170M;
 		break;
Signature · 1 line
2.1.0