aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx88
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-09-20 08:24:58 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-03 05:36:40 -0500
commitc0d5b5fbbe1b13c5d474b58bf89dd7ff2e6eb6e1 (patch)
treebd8367b2b88c773239ade3a6f94f11c9757c66f9 /drivers/media/pci/cx88
parent98822de9ae22083658104e43d52f2cb0f3df1138 (diff)
[media] cx88: fix VBI support
Now works with both NTSC and PAL. Tested with CC/XDS for NTSC and teletext/WSS for PAL. The start lines were wrong, the WSS signal wasn't captured and there was no difference between NTSC and PAL w.r.t. the count[] values so NTSC returned way too many lines. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/pci/cx88')
-rw-r--r--drivers/media/pci/cx88/cx88-vbi.c28
-rw-r--r--drivers/media/pci/cx88/cx88.h3
2 files changed, 22 insertions, 9 deletions
diff --git a/drivers/media/pci/cx88/cx88-vbi.c b/drivers/media/pci/cx88/cx88-vbi.c
index 042f54597a9b..6ab6e27648f6 100644
--- a/drivers/media/pci/cx88/cx88-vbi.c
+++ b/drivers/media/pci/cx88/cx88-vbi.c
@@ -23,20 +23,22 @@ int cx8800_vbi_fmt (struct file *file, void *priv,
23 f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH; 23 f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH;
24 f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; 24 f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
25 f->fmt.vbi.offset = 244; 25 f->fmt.vbi.offset = 244;
26 f->fmt.vbi.count[0] = VBI_LINE_COUNT;
27 f->fmt.vbi.count[1] = VBI_LINE_COUNT;
28 26
29 if (dev->core->tvnorm & V4L2_STD_525_60) { 27 if (dev->core->tvnorm & V4L2_STD_525_60) {
30 /* ntsc */ 28 /* ntsc */
31 f->fmt.vbi.sampling_rate = 28636363; 29 f->fmt.vbi.sampling_rate = 28636363;
32 f->fmt.vbi.start[0] = 10; 30 f->fmt.vbi.start[0] = 10;
33 f->fmt.vbi.start[1] = 273; 31 f->fmt.vbi.start[1] = 273;
32 f->fmt.vbi.count[0] = VBI_LINE_NTSC_COUNT;
33 f->fmt.vbi.count[1] = VBI_LINE_NTSC_COUNT;
34 34
35 } else if (dev->core->tvnorm & V4L2_STD_625_50) { 35 } else if (dev->core->tvnorm & V4L2_STD_625_50) {
36 /* pal */ 36 /* pal */
37 f->fmt.vbi.sampling_rate = 35468950; 37 f->fmt.vbi.sampling_rate = 35468950;
38 f->fmt.vbi.start[0] = 7 -1; 38 f->fmt.vbi.start[0] = V4L2_VBI_ITU_625_F1_START + 5;
39 f->fmt.vbi.start[1] = 319 -1; 39 f->fmt.vbi.start[1] = V4L2_VBI_ITU_625_F2_START + 5;
40 f->fmt.vbi.count[0] = VBI_LINE_PAL_COUNT;
41 f->fmt.vbi.count[1] = VBI_LINE_PAL_COUNT;
40 } 42 }
41 return 0; 43 return 0;
42} 44}
@@ -111,8 +113,13 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
111 unsigned int *num_buffers, unsigned int *num_planes, 113 unsigned int *num_buffers, unsigned int *num_planes,
112 unsigned int sizes[], void *alloc_ctxs[]) 114 unsigned int sizes[], void *alloc_ctxs[])
113{ 115{
116 struct cx8800_dev *dev = q->drv_priv;
117
114 *num_planes = 1; 118 *num_planes = 1;
115 sizes[0] = VBI_LINE_COUNT * VBI_LINE_LENGTH * 2; 119 if (dev->core->tvnorm & V4L2_STD_525_60)
120 sizes[0] = VBI_LINE_NTSC_COUNT * VBI_LINE_LENGTH * 2;
121 else
122 sizes[0] = VBI_LINE_PAL_COUNT * VBI_LINE_LENGTH * 2;
116 return 0; 123 return 0;
117} 124}
118 125
@@ -122,10 +129,15 @@ static int buffer_prepare(struct vb2_buffer *vb)
122 struct cx8800_dev *dev = vb->vb2_queue->drv_priv; 129 struct cx8800_dev *dev = vb->vb2_queue->drv_priv;
123 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb); 130 struct cx88_buffer *buf = container_of(vb, struct cx88_buffer, vb);
124 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); 131 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
132 unsigned int lines;
125 unsigned int size; 133 unsigned int size;
126 int rc; 134 int rc;
127 135
128 size = VBI_LINE_COUNT * VBI_LINE_LENGTH * 2; 136 if (dev->core->tvnorm & V4L2_STD_525_60)
137 lines = VBI_LINE_NTSC_COUNT;
138 else
139 lines = VBI_LINE_PAL_COUNT;
140 size = lines * VBI_LINE_LENGTH * 2;
129 if (vb2_plane_size(vb, 0) < size) 141 if (vb2_plane_size(vb, 0) < size)
130 return -EINVAL; 142 return -EINVAL;
131 vb2_set_plane_payload(vb, 0, size); 143 vb2_set_plane_payload(vb, 0, size);
@@ -135,9 +147,9 @@ static int buffer_prepare(struct vb2_buffer *vb)
135 return -EIO; 147 return -EIO;
136 148
137 cx88_risc_buffer(dev->pci, &buf->risc, sgt->sgl, 149 cx88_risc_buffer(dev->pci, &buf->risc, sgt->sgl,
138 0, VBI_LINE_LENGTH * VBI_LINE_COUNT, 150 0, VBI_LINE_LENGTH * lines,
139 VBI_LINE_LENGTH, 0, 151 VBI_LINE_LENGTH, 0,
140 VBI_LINE_COUNT); 152 lines);
141 return 0; 153 return 0;
142} 154}
143 155
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 2fa4aa93e503..3b0ae754f165 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -61,7 +61,8 @@
61#define FORMAT_FLAGS_PACKED 0x01 61#define FORMAT_FLAGS_PACKED 0x01
62#define FORMAT_FLAGS_PLANAR 0x02 62#define FORMAT_FLAGS_PLANAR 0x02
63 63
64#define VBI_LINE_COUNT 17 64#define VBI_LINE_PAL_COUNT 18
65#define VBI_LINE_NTSC_COUNT 12
65#define VBI_LINE_LENGTH 2048 66#define VBI_LINE_LENGTH 2048
66 67
67#define AUD_RDS_LINES 4 68#define AUD_RDS_LINES 4