summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgignore5
-rw-r--r--linux/drivers/media/video/cx88/cx88-core.c8
-rw-r--r--linux/drivers/media/video/cx88/cx88-vbi.c4
-rw-r--r--linux/drivers/media/video/cx88/cx88.h2
-rw-r--r--linux/drivers/media/video/vivi.c1
-rw-r--r--test/Makefile2
-rw-r--r--test/ioctl-test.c4
-rw-r--r--test/sliced-vbi-detect.c142
-rw-r--r--test/sliced-vbi-test.c22
-rw-r--r--test/vbi-test.c90
-rw-r--r--v4l/Makefile2
11 files changed, 189 insertions, 93 deletions
diff --git a/.hgignore b/.hgignore
index 67f850534..3bc3d3a79 100644
--- a/.hgignore
+++ b/.hgignore
@@ -16,3 +16,8 @@ v4l/Modules.symvers
v4l/scripts/Kconfig
v4l/scripts/Kconfig.kern
v4l/config-compat.h
+test/ioctl-test
+test/sliced-vbi-detect
+test/sliced-vbi-test
+test/vbi-test
+
diff --git a/linux/drivers/media/video/cx88/cx88-core.c b/linux/drivers/media/video/cx88/cx88-core.c
index b657894e8..49dfc04d9 100644
--- a/linux/drivers/media/video/cx88/cx88-core.c
+++ b/linux/drivers/media/video/cx88/cx88-core.c
@@ -717,7 +717,7 @@ static unsigned int inline norm_htotal(struct cx88_tvnorm *norm)
static unsigned int inline norm_vbipack(struct cx88_tvnorm *norm)
{
- return (norm->id & V4L2_STD_625_50) ? 511 : 288;
+ return (norm->id & V4L2_STD_625_50) ? 511 : 400;
}
int cx88_set_scale(struct cx88_core *core, unsigned int width, unsigned int height,
@@ -976,9 +976,9 @@ int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
htotal, cx_read(MO_HTOTAL), (u32)tmp64);
cx_write(MO_HTOTAL, htotal);
- // vbi stuff
- cx_write(MO_VBI_PACKET, ((1 << 11) | /* (norm_vdelay(norm) << 11) | */
- norm_vbipack(norm)));
+ // vbi stuff, set vbi offset to 10 (for 20 Clk*2 pixels), this makes
+ // the effective vbi offset ~244 samples, the same as the Bt8x8
+ cx_write(MO_VBI_PACKET, (10<<11) | norm_vbipack(norm));
// this is needed as well to set all tvnorm parameter
cx88_set_scale(core, 320, 240, V4L2_FIELD_INTERLACED);
diff --git a/linux/drivers/media/video/cx88/cx88-vbi.c b/linux/drivers/media/video/cx88/cx88-vbi.c
index 749187d69..5cd0ee9ce 100644
--- a/linux/drivers/media/video/cx88/cx88-vbi.c
+++ b/linux/drivers/media/video/cx88/cx88-vbi.c
@@ -35,8 +35,8 @@ void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f)
if (dev->core->tvnorm->id & V4L2_STD_525_60) {
/* ntsc */
f->fmt.vbi.sampling_rate = 28636363;
- f->fmt.vbi.start[0] = 10 -1;
- f->fmt.vbi.start[1] = 273 -1;
+ f->fmt.vbi.start[0] = 10;
+ f->fmt.vbi.start[1] = 273;
} else if (dev->core->tvnorm->id & V4L2_STD_625_50) {
/* pal */
diff --git a/linux/drivers/media/video/cx88/cx88.h b/linux/drivers/media/video/cx88/cx88.h
index 88fff918d..0c7986572 100644
--- a/linux/drivers/media/video/cx88/cx88.h
+++ b/linux/drivers/media/video/cx88/cx88.h
@@ -40,7 +40,7 @@
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
#include <linux/mutex.h>
#endif
-#define CX88_VERSION_CODE KERNEL_VERSION(0,0,5)
+#define CX88_VERSION_CODE KERNEL_VERSION(0,0,6)
#ifndef TRUE
# define TRUE (1==1)
diff --git a/linux/drivers/media/video/vivi.c b/linux/drivers/media/video/vivi.c
index 170712515..21fbaa009 100644
--- a/linux/drivers/media/video/vivi.c
+++ b/linux/drivers/media/video/vivi.c
@@ -25,6 +25,7 @@
#include <linux/pci.h>
#include <linux/random.h>
#include <linux/version.h>
+#include "compat.h"
#include <linux/videodev2.h>
#include <linux/dma-mapping.h>
#ifdef CONFIG_VIDEO_V4L1_COMPAT
diff --git a/test/Makefile b/test/Makefile
index 2bfdcb4dc..8623e4d98 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,4 @@
-FILES = ioctl-test sliced-vbi-test sliced-vbi-detect
+FILES = ioctl-test sliced-vbi-test sliced-vbi-detect vbi-test
CC = gcc
LIBS =
CFLAGS = -O3 -Wall -fomit-frame-pointer -funroll-loops -g -I ../linux/include
diff --git a/test/ioctl-test.c b/test/ioctl-test.c
index 3f2fefc44..b7dd87e94 100644
--- a/test/ioctl-test.c
+++ b/test/ioctl-test.c
@@ -6,7 +6,7 @@
and v4l_decoder.h. These messages shouldn't be handled by video
driver itself, but for internal video and/or audio decoders.
- Copyright (C) 2005 Mauro Carvalho Chehab <mchehab@brturbo.com.br>
+ Copyright (C) 2005 Mauro Carvalho Chehab <mchehab@infradead.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -200,7 +200,7 @@ int main (void)
char *device="/dev/video0";
union v4l_parms p;
- if ((fd = open(device, O_RDONLY)) < 0) {
+ if ((fd = open(device, O_RDONLY)) < 0) {
perror("Couldn't open video0");
return(-1);
}
diff --git a/test/sliced-vbi-detect.c b/test/sliced-vbi-detect.c
index 3fe33f6cc..9e2a3b2c5 100644
--- a/test/sliced-vbi-detect.c
+++ b/test/sliced-vbi-detect.c
@@ -47,45 +47,45 @@
static void detect(int fh, struct v4l2_sliced_vbi_format *fmt)
{
struct v4l2_sliced_vbi_data *buf = malloc(fmt->io_size);
- int cnt;
+ int cnt;
- for (cnt = 0; cnt < 5; cnt++) {
+ for (cnt = 0; cnt < 5; cnt++) {
int size = read(fh, buf, fmt->io_size);
int i;
if (size <= 0) {
- printf("size = %d\n", size);
+ printf("size = %d\n", size);
break;
- }
- if (cnt == 0)
- continue;
+ }
+ if (cnt == 0)
+ continue;
for (i = 0; i < size / sizeof(*buf); i++) {
- int field, line;
-
- line = buf[i].line;
- field = buf[i].field;
- if (buf[i].id == 0)
- continue;
- if (line < 0 || line >= 24) {
- printf("line %d out of range\n", line);
- free(buf);
- return;
- }
- fmt->service_lines[field][line] |= buf[i].id;
+ int field, line;
+
+ line = buf[i].line;
+ field = buf[i].field;
+ if (buf[i].id == 0)
+ continue;
+ if (line < 0 || line >= 24) {
+ printf("line %d out of range\n", line);
+ free(buf);
+ return;
+ }
+ fmt->service_lines[field][line] |= buf[i].id;
}
}
- free(buf);
+ free(buf);
}
void v2s(int id)
{
- switch (id) {
- case V4L2_SLICED_TELETEXT_B: printf(" TELETEXT"); break;
- case V4L2_SLICED_CAPTION_525: printf(" CC"); break;
- case V4L2_SLICED_WSS_625: printf(" WSS"); break;
- case V4L2_SLICED_VPS: printf(" VPS"); break;
- default: printf(" UNKNOWN %x", id); break;
- }
+ switch (id) {
+ case V4L2_SLICED_TELETEXT_B: printf(" TELETEXT"); break;
+ case V4L2_SLICED_CAPTION_525: printf(" CC"); break;
+ case V4L2_SLICED_WSS_625: printf(" WSS"); break;
+ case V4L2_SLICED_VPS: printf(" VPS"); break;
+ default: printf(" UNKNOWN %x", id); break;
+ }
}
int main(int argc, char **argv)
@@ -94,53 +94,53 @@ int main(int argc, char **argv)
struct v4l2_format vbifmt;
struct v4l2_sliced_vbi_format vbiresult;
int fh;
- int f, i, b;
+ int f, i, b;
if (argc == 2)
- device = argv[1];
- fh = open(device, O_RDONLY);
-
- if (fh == -1) {
- fprintf(stderr, "cannot open %s\n", device);
- return 1;
- }
- memset(&vbiresult, 0, sizeof(vbiresult));
- for (i = 0; i < 16; i++) {
- int l;
- int set = 0;
-
- memset(&vbifmt, 0, sizeof(vbifmt));
- vbifmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
- for (l = 0; l < 24; l++) {
- vbifmt.fmt.sliced.service_lines[0][l] = 1 << i;
- vbifmt.fmt.sliced.service_lines[1][l] = 1 << i;
- }
- if (ioctl(fh, VIDIOC_S_FMT, &vbifmt) < 0) {
- if (errno == EINVAL)
- continue;
- perror("IVTV_IOC_S_VBI_FMT");
- exit(-1);
- }
- vbiresult.io_size = vbifmt.fmt.sliced.io_size;
- for (l = 0; l < 24; l++) {
- set |= vbifmt.fmt.sliced.service_lines[0][l] |
- vbifmt.fmt.sliced.service_lines[1][l];
- }
- detect(fh, &vbiresult);
- }
+ device = argv[1];
+ fh = open(device, O_RDONLY);
+
+ if (fh == -1) {
+ fprintf(stderr, "cannot open %s\n", device);
+ return 1;
+ }
+ memset(&vbiresult, 0, sizeof(vbiresult));
+ for (i = 0; i < 16; i++) {
+ int l;
+ int set = 0;
+
+ memset(&vbifmt, 0, sizeof(vbifmt));
+ vbifmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
+ for (l = 0; l < 24; l++) {
+ vbifmt.fmt.sliced.service_lines[0][l] = 1 << i;
+ vbifmt.fmt.sliced.service_lines[1][l] = 1 << i;
+ }
+ if (ioctl(fh, VIDIOC_S_FMT, &vbifmt) < 0) {
+ if (errno == EINVAL)
+ continue;
+ perror("IVTV_IOC_S_VBI_FMT");
+ exit(-1);
+ }
+ vbiresult.io_size = vbifmt.fmt.sliced.io_size;
+ for (l = 0; l < 24; l++) {
+ set |= vbifmt.fmt.sliced.service_lines[0][l] |
+ vbifmt.fmt.sliced.service_lines[1][l];
+ }
+ detect(fh, &vbiresult);
+ }
close(fh);
- for (f = 0; f < 2; f++) {
- printf("Field %d:\n", f);
- for (i = 6; i < 24; i++) {
- unsigned set = vbiresult.service_lines[f][i];
-
- printf(" Line %2d:", i);
- for (b = 0; b < 16; b++) {
- if (set & (1 << b))
- v2s(1 << b);
- }
- printf("\n");
- }
- }
+ for (f = 0; f < 2; f++) {
+ printf("Field %d:\n", f);
+ for (i = 6; i < 24; i++) {
+ unsigned set = vbiresult.service_lines[f][i];
+
+ printf(" Line %2d:", i);
+ for (b = 0; b < 16; b++) {
+ if (set & (1 << b))
+ v2s(1 << b);
+ }
+ printf("\n");
+ }
+ }
return 0;
}
diff --git a/test/sliced-vbi-test.c b/test/sliced-vbi-test.c
index a44f75565..ae4e1b27d 100644
--- a/test/sliced-vbi-test.c
+++ b/test/sliced-vbi-test.c
@@ -397,24 +397,24 @@ void process(struct v4l2_sliced_vbi_data *s)
if (s->id == 0)
return;
- //printf("%04d: line %02u field %d type %x\n", frames, s->line, s->field, s->id);
+ //printf("%04d: line %02u field %d type %x\n", frames, s->line, s->field, s->id);
switch (s->id) {
case V4L2_SLICED_TELETEXT_B:
printf("teletext\n");
break;
case V4L2_SLICED_VPS:
- if (s->line != 16 || s->field)
- break;
+ if (s->line != 16 || s->field)
+ break;
decode_vps(s);
break;
case V4L2_SLICED_WSS_625:
- if (s->line != 23 || s->field)
- break;
+ if (s->line != 23 || s->field)
+ break;
decode_wss(s);
break;
case V4L2_SLICED_CAPTION_525:
- if (s->line != 21)
- break;
+ if (s->line != 21)
+ break;
decode_cc(s);
break;
default:
@@ -427,7 +427,7 @@ int main(int argc, char **argv)
{
char *device = "/dev/vbi0";
struct v4l2_format fmt;
- v4l2_std_id std;
+ v4l2_std_id std;
struct v4l2_sliced_vbi_data *buf;
int fh;
@@ -440,10 +440,10 @@ int main(int argc, char **argv)
return 1;
}
- setbuf(stdout, NULL);
+ setbuf(stdout, NULL);
ioctl(fh, VIDIOC_G_STD, &std);
- fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
+ fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
fmt.fmt.sliced.service_set = (std & V4L2_STD_NTSC) ? V4L2_SLICED_VBI_525 : V4L2_SLICED_VBI_625;
fmt.fmt.sliced.reserved[0] = 0;
fmt.fmt.sliced.reserved[1] = 0;
@@ -461,7 +461,7 @@ int main(int argc, char **argv)
if (size <= 0)
break;
- frames++;
+ frames++;
for (i = 0; i < size / sizeof(struct v4l2_sliced_vbi_data); i++) {
process(&buf[i]);
}
diff --git a/test/vbi-test.c b/test/vbi-test.c
new file mode 100644
index 000000000..27fd7a528
--- /dev/null
+++ b/test/vbi-test.c
@@ -0,0 +1,90 @@
+/*
+ v4l-ioctl-test - This small utility checks VBI format
+
+ Copyright (C) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#define __user
+#include <linux/videodev.h>
+
+/* All possible parameters used on v4l ioctls */
+union v4l_parms {
+ /* V4L1 structs */
+ struct vbi_format v1;
+
+ /* V4L2 structs */
+ struct v4l2_format v2;
+};
+
+/* All defined ioctls */
+int ioctls[] = {
+ /* V4L ioctls */
+
+ VIDIOCGVBIFMT,/* struct vbi_format */
+
+ /* V4L2 ioctls */
+
+ VIDIOC_G_FMT,/* struct v4l2_format */
+};
+#define S_IOCTLS sizeof(ioctls)/sizeof(ioctls[0])
+
+/********************************************************************/
+int main (void)
+{
+ int fd=0, ret=0;
+ char *device="/dev/video0";
+ union v4l_parms p;
+
+ if ((fd = open(device, O_RDONLY)) < 0) {
+ perror("Couldn't open video0");
+ return(-1);
+ }
+
+
+ /* V4L1 call */
+ memset(&p,0,sizeof(p));
+ ret=ioctl(fd,VIDIOCGVBIFMT, (void *) &p);
+
+ printf ("V4L1 call: ret=%i: sampling_rate=%d, samples_per_line=%d, "
+ "sample_format=%d, start=%d/%d, count=%d/%d, flags=%d\n", ret,
+ p.v1.sampling_rate,p.v1.samples_per_line, p.v1.sample_format,
+ p.v1.start[0],p.v1.start[1],p.v1.count[0],p.v1.count[1],p.v1.flags);
+
+
+ /* V4L2 call */
+ memset(&p,0,sizeof(p));
+ p.v2.type=V4L2_BUF_TYPE_VBI_CAPTURE;
+ ret=ioctl(fd,VIDIOC_G_FMT, (void *) &p);
+
+ printf ("V4L2 call: ret=%i: sampling_rate=%d, samples_per_line=%d, "
+ "sample_format=%d, offset=%d, start=%d/%d, count=%d/%d\n", ret,
+ p.v2.fmt.vbi.sampling_rate,p.v2.fmt.vbi.samples_per_line,
+ p.v2.fmt.vbi.sample_format,p.v2.fmt.vbi.offset,
+ p.v2.fmt.vbi.start[0],p.v2.fmt.vbi.start[1],
+ p.v2.fmt.vbi.count[0],p.v2.fmt.vbi.count[1]);
+
+ close (fd);
+
+ return (0);
+}
diff --git a/v4l/Makefile b/v4l/Makefile
index 3ba4603f3..b8eba1a44 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -196,7 +196,7 @@ config-compat.h:: .myconfig
@echo >> config-compat.h
@grep "CONFIG\_" .myconfig | grep -v "\:\= n" | \
sed s/"CONFIG\_"/"\#undef CONFIG\_"/1 | \
- sed s/"\:\= ."/""/1 >> config-compat.h >> config-compat.h
+ sed s/"\:\= .*"/""/1 >> config-compat.h >> config-compat.h
@echo >> config-compat.h
@grep "CONFIG\_" .myconfig | grep -v "\:\= n" | \
sed s/"CONFIG\_"/"\#define CONFIG\_"/1 | \