2
v4l-ioctl-test - This small utility checks VBI format
4
Copyright (C) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
#include <sys/types.h>
26
#include <sys/ioctl.h>
28
#include <linux/videodev.h>
30
/* All possible parameters used on v4l ioctls */
32
#ifdef CONFIG_VIDEO_V4L1_COMPAT
38
struct v4l2_format v2;
41
/* All defined ioctls */
43
#ifdef CONFIG_VIDEO_V4L1_COMPAT
46
VIDIOCGVBIFMT,/* struct vbi_format */
51
VIDIOC_G_FMT,/* struct v4l2_format */
53
#define S_IOCTLS sizeof(ioctls)/sizeof(ioctls[0])
55
/********************************************************************/
59
char *device="/dev/video0";
62
if ((fd = open(device, O_RDONLY)) < 0) {
63
perror("Couldn't open video0");
68
#ifdef CONFIG_VIDEO_V4L1_COMPAT
70
memset(&p,0,sizeof(p));
71
ret=ioctl(fd,VIDIOCGVBIFMT, (void *) &p);
73
printf ("V4L1 call: ret=%i: sampling_rate=%d, samples_per_line=%d, "
74
"sample_format=%d, start=%d/%d, count=%d/%d, flags=%d\n", ret,
75
p.v1.sampling_rate,p.v1.samples_per_line, p.v1.sample_format,
76
p.v1.start[0],p.v1.start[1],p.v1.count[0],p.v1.count[1],p.v1.flags);
81
memset(&p,0,sizeof(p));
82
p.v2.type=V4L2_BUF_TYPE_VBI_CAPTURE;
83
ret=ioctl(fd,VIDIOC_G_FMT, (void *) &p);
85
printf ("V4L2 call: ret=%i: sampling_rate=%d, samples_per_line=%d, "
86
"sample_format=%d, offset=%d, start=%d/%d, count=%d/%d\n", ret,
87
p.v2.fmt.vbi.sampling_rate,p.v2.fmt.vbi.samples_per_line,
88
p.v2.fmt.vbi.sample_format,p.v2.fmt.vbi.offset,
89
p.v2.fmt.vbi.start[0],p.v2.fmt.vbi.start[1],
90
p.v2.fmt.vbi.count[0],p.v2.fmt.vbi.count[1]);