summaryrefslogtreecommitdiff
path: root/test/sliced-vbi-detect.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-05-15 23:37:37 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-05-15 23:37:37 -0300
commite4a9fb69a7c69cc46bd393234766c32403ad8f56 (patch)
treedcf44c052a8a2d7f8603626d2611a221c73b0a47 /test/sliced-vbi-detect.c
parentda14f3340bd6879661ed106f47b8ae0101594e22 (diff)
parenta678371aaa80825811e0e97e74021c11776704a2 (diff)
downloadmediapointer-dvb-s2-e4a9fb69a7c69cc46bd393234766c32403ad8f56.tar.gz
mediapointer-dvb-s2-e4a9fb69a7c69cc46bd393234766c32403ad8f56.tar.bz2
merge: http://linuxtv.org/hg/~quincy/v4l-dvb
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'test/sliced-vbi-detect.c')
-rw-r--r--test/sliced-vbi-detect.c142
1 files changed, 71 insertions, 71 deletions
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;
}