[PATCH] v4l: saa7134 ntsc vbi fix

This patch fixes NTSC VBI capturing in the saa7134 driver.

Signed-off-by: Michael H. Schimek <mschimek@gmx.at>
Cc: <video4linux-list@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Michael Schimek and committed by
Linus Torvalds
f246a817 93b43f13

+33 -29
+6 -6
drivers/media/video/saa7134/saa7134-vbi.c
··· 60 saa_writeb(SAA7134_VBI_H_START2(task), norm->h_start >> 8); 61 saa_writeb(SAA7134_VBI_H_STOP1(task), norm->h_stop & 0xff); 62 saa_writeb(SAA7134_VBI_H_STOP2(task), norm->h_stop >> 8); 63 - saa_writeb(SAA7134_VBI_V_START1(task), norm->vbi_v_start & 0xff); 64 - saa_writeb(SAA7134_VBI_V_START2(task), norm->vbi_v_start >> 8); 65 - saa_writeb(SAA7134_VBI_V_STOP1(task), norm->vbi_v_stop & 0xff); 66 - saa_writeb(SAA7134_VBI_V_STOP2(task), norm->vbi_v_stop >> 8); 67 68 saa_writeb(SAA7134_VBI_H_SCALE_INC1(task), VBI_SCALE & 0xff); 69 saa_writeb(SAA7134_VBI_H_SCALE_INC2(task), VBI_SCALE >> 8); ··· 127 unsigned int lines, llength, size; 128 int err; 129 130 - lines = norm->vbi_v_stop - norm->vbi_v_start +1; 131 if (lines > VBI_LINE_COUNT) 132 lines = VBI_LINE_COUNT; 133 #if 1 ··· 177 struct saa7134_dev *dev = fh->dev; 178 int llength,lines; 179 180 - lines = dev->tvnorm->vbi_v_stop - dev->tvnorm->vbi_v_start +1; 181 #if 1 182 llength = VBI_LINE_LENGTH; 183 #else
··· 60 saa_writeb(SAA7134_VBI_H_START2(task), norm->h_start >> 8); 61 saa_writeb(SAA7134_VBI_H_STOP1(task), norm->h_stop & 0xff); 62 saa_writeb(SAA7134_VBI_H_STOP2(task), norm->h_stop >> 8); 63 + saa_writeb(SAA7134_VBI_V_START1(task), norm->vbi_v_start_0 & 0xff); 64 + saa_writeb(SAA7134_VBI_V_START2(task), norm->vbi_v_start_0 >> 8); 65 + saa_writeb(SAA7134_VBI_V_STOP1(task), norm->vbi_v_stop_0 & 0xff); 66 + saa_writeb(SAA7134_VBI_V_STOP2(task), norm->vbi_v_stop_0 >> 8); 67 68 saa_writeb(SAA7134_VBI_H_SCALE_INC1(task), VBI_SCALE & 0xff); 69 saa_writeb(SAA7134_VBI_H_SCALE_INC2(task), VBI_SCALE >> 8); ··· 127 unsigned int lines, llength, size; 128 int err; 129 130 + lines = norm->vbi_v_stop_0 - norm->vbi_v_start_0 +1; 131 if (lines > VBI_LINE_COUNT) 132 lines = VBI_LINE_COUNT; 133 #if 1 ··· 177 struct saa7134_dev *dev = fh->dev; 178 int llength,lines; 179 180 + lines = dev->tvnorm->vbi_v_stop_0 - dev->tvnorm->vbi_v_start_0 +1; 181 #if 1 182 llength = VBI_LINE_LENGTH; 183 #else
+23 -20
drivers/media/video/saa7134/saa7134-video.c
··· 158 .h_stop = 719, \ 159 .video_v_start = 24, \ 160 .video_v_stop = 311, \ 161 - .vbi_v_start = 7, \ 162 - .vbi_v_stop = 22, \ 163 .src_timing = 4 164 165 #define NORM_525_60 \ 166 .h_start = 0, \ 167 .h_stop = 703, \ 168 - .video_v_start = 22, \ 169 - .video_v_stop = 22+239, \ 170 - .vbi_v_start = 10, /* FIXME */ \ 171 - .vbi_v_stop = 21, /* FIXME */ \ 172 - .src_timing = 1 173 174 static struct saa7134_tvnorm tvnorms[] = { 175 { ··· 276 277 .h_start = 0, 278 .h_stop = 719, 279 - .video_v_start = 22, 280 - .video_v_stop = 22+239, 281 - .vbi_v_start = 10, /* FIXME */ 282 - .vbi_v_stop = 21, /* FIXME */ 283 - .src_timing = 1, 284 285 .sync_control = 0x18, 286 .luma_control = 0x40, ··· 338 .default_value = 0, 339 .type = V4L2_CTRL_TYPE_INTEGER, 340 },{ 341 - .id = V4L2_CID_VFLIP, 342 - .name = "vertical flip", 343 .minimum = 0, 344 .maximum = 1, 345 .type = V4L2_CTRL_TYPE_BOOLEAN, ··· 485 dev->crop_bounds.width = norm->h_stop - norm->h_start +1; 486 dev->crop_defrect.width = norm->h_stop - norm->h_start +1; 487 488 - dev->crop_bounds.top = (norm->vbi_v_stop+1)*2; 489 dev->crop_defrect.top = norm->video_v_start*2; 490 dev->crop_bounds.height = ((norm->id & V4L2_STD_525_60) ? 524 : 624) 491 - dev->crop_bounds.top; ··· 1067 case V4L2_CID_PRIVATE_INVERT: 1068 c->value = dev->ctl_invert; 1069 break; 1070 - case V4L2_CID_VFLIP: 1071 c->value = dev->ctl_mirror; 1072 break; 1073 case V4L2_CID_PRIVATE_Y_EVEN: ··· 1142 saa_writeb(SAA7134_DEC_CHROMA_SATURATION, 1143 dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation); 1144 break; 1145 - case V4L2_CID_VFLIP: 1146 dev->ctl_mirror = c->value; 1147 restart_overlay = 1; 1148 break; ··· 1410 f->fmt.vbi.samples_per_line = 2048 /* VBI_LINE_LENGTH */; 1411 f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; 1412 f->fmt.vbi.offset = 64 * 4; 1413 - f->fmt.vbi.start[0] = norm->vbi_v_start; 1414 - f->fmt.vbi.count[0] = norm->vbi_v_stop - norm->vbi_v_start +1; 1415 - f->fmt.vbi.start[1] = norm->video_v_stop + norm->vbi_v_start +1; 1416 f->fmt.vbi.count[1] = f->fmt.vbi.count[0]; 1417 f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */ 1418
··· 158 .h_stop = 719, \ 159 .video_v_start = 24, \ 160 .video_v_stop = 311, \ 161 + .vbi_v_start_0 = 7, \ 162 + .vbi_v_stop_0 = 22, \ 163 + .vbi_v_start_1 = 319, \ 164 .src_timing = 4 165 166 #define NORM_525_60 \ 167 .h_start = 0, \ 168 .h_stop = 703, \ 169 + .video_v_start = 23, \ 170 + .video_v_stop = 262, \ 171 + .vbi_v_start_0 = 10, \ 172 + .vbi_v_stop_0 = 21, \ 173 + .vbi_v_start_1 = 273, \ 174 + .src_timing = 7 175 176 static struct saa7134_tvnorm tvnorms[] = { 177 { ··· 274 275 .h_start = 0, 276 .h_stop = 719, 277 + .video_v_start = 23, 278 + .video_v_stop = 262, 279 + .vbi_v_start_0 = 10, 280 + .vbi_v_stop_0 = 21, 281 + .vbi_v_start_1 = 273, 282 + .src_timing = 7, 283 284 .sync_control = 0x18, 285 .luma_control = 0x40, ··· 335 .default_value = 0, 336 .type = V4L2_CTRL_TYPE_INTEGER, 337 },{ 338 + .id = V4L2_CID_HFLIP, 339 + .name = "Mirror", 340 .minimum = 0, 341 .maximum = 1, 342 .type = V4L2_CTRL_TYPE_BOOLEAN, ··· 482 dev->crop_bounds.width = norm->h_stop - norm->h_start +1; 483 dev->crop_defrect.width = norm->h_stop - norm->h_start +1; 484 485 + dev->crop_bounds.top = (norm->vbi_v_stop_0+1)*2; 486 dev->crop_defrect.top = norm->video_v_start*2; 487 dev->crop_bounds.height = ((norm->id & V4L2_STD_525_60) ? 524 : 624) 488 - dev->crop_bounds.top; ··· 1064 case V4L2_CID_PRIVATE_INVERT: 1065 c->value = dev->ctl_invert; 1066 break; 1067 + case V4L2_CID_HFLIP: 1068 c->value = dev->ctl_mirror; 1069 break; 1070 case V4L2_CID_PRIVATE_Y_EVEN: ··· 1139 saa_writeb(SAA7134_DEC_CHROMA_SATURATION, 1140 dev->ctl_invert ? -dev->ctl_saturation : dev->ctl_saturation); 1141 break; 1142 + case V4L2_CID_HFLIP: 1143 dev->ctl_mirror = c->value; 1144 restart_overlay = 1; 1145 break; ··· 1407 f->fmt.vbi.samples_per_line = 2048 /* VBI_LINE_LENGTH */; 1408 f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; 1409 f->fmt.vbi.offset = 64 * 4; 1410 + f->fmt.vbi.start[0] = norm->vbi_v_start_0; 1411 + f->fmt.vbi.count[0] = norm->vbi_v_stop_0 - norm->vbi_v_start_0 +1; 1412 + f->fmt.vbi.start[1] = norm->vbi_v_start_1; 1413 f->fmt.vbi.count[1] = f->fmt.vbi.count[0]; 1414 f->fmt.vbi.flags = 0; /* VBI_UNSYNC VBI_INTERLACED */ 1415
+4 -3
drivers/media/video/saa7134/saa7134.h
··· 21 */ 22 23 #include <linux/version.h> 24 - #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,12) 25 26 #include <linux/pci.h> 27 #include <linux/i2c.h> ··· 91 unsigned int h_stop; 92 unsigned int video_v_start; 93 unsigned int video_v_stop; 94 - unsigned int vbi_v_start; 95 - unsigned int vbi_v_stop; 96 unsigned int src_timing; 97 }; 98 99 struct saa7134_tvaudio {
··· 21 */ 22 23 #include <linux/version.h> 24 + #define SAA7134_VERSION_CODE KERNEL_VERSION(0,2,13) 25 26 #include <linux/pci.h> 27 #include <linux/i2c.h> ··· 91 unsigned int h_stop; 92 unsigned int video_v_start; 93 unsigned int video_v_stop; 94 + unsigned int vbi_v_start_0; 95 + unsigned int vbi_v_stop_0; 96 unsigned int src_timing; 97 + unsigned int vbi_v_start_1; 98 }; 99 100 struct saa7134_tvaudio {