Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin M. Schwartz <bens@alum.mit.edu>2010-07-25 21:46:10 (GMT)
committer Benjamin M. Schwartz <bens@alum.mit.edu>2010-07-25 21:46:10 (GMT)
commit5717b6e06812ef3f1bc8646487b46c438892c65e (patch)
tree033076803d93e08b518d62f6e6b4aed95eb614b0
parentfe53992344e73a3adb5afa0e088bc04a4f0cdd98 (diff)
Add a framerate control, cargo-culting Corbet's code.
-rw-r--r--capture.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/capture.c b/capture.c
index 086733f..437cd65 100644
--- a/capture.c
+++ b/capture.c
@@ -66,6 +66,20 @@ xioctl (int fd,
return r;
}
+static int
+set_framerate (int numerator,
+ int denominator)
+{
+ struct v4l2_streamparm parm;
+ struct v4l2_fract *tpf = &(parm.parm.capture.timeperframe);
+ memset(&parm, 0, sizeof(parm));
+ parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ tpf->numerator = numerator;
+ tpf->denominator = denominator;
+ return xioctl(fd, VIDIOC_S_PARM, &parm);
+}
+
static void
process_image (const void * p)
{
@@ -590,11 +604,12 @@ usage (FILE * fp,
"-r | --read Use read() calls\n"
"-u | --userp Use application allocated buffers\n"
"-n | --numframes Number of frames to acquire (default=1)\n"
+ "-f | --framerate Frame rate at which to acquire (default: use driver's default)\n"
"",
argv[0]);
}
-static const char short_options [] = "d:hmrun";
+static const char short_options [] = "d:hmrunf";
static const struct option
long_options [] = {
@@ -604,6 +619,7 @@ long_options [] = {
{ "read", no_argument, NULL, 'r' },
{ "userp", no_argument, NULL, 'u' },
{ "numframes", required_argument, NULL, 'n' },
+ { "framerate", required_argument, NULL, 'f' },
{ 0, 0, 0, 0 }
};
@@ -617,6 +633,7 @@ main (int argc,
int index;
int c;
unsigned int numframes = 1;
+ unsigned int framerate = 0;
c = getopt_long (argc, argv,
short_options, long_options,
@@ -653,6 +670,10 @@ main (int argc,
numframes = atoi(optarg);
break;
+ case 'f':
+ framerate = atoi(optarg);
+ break;
+
default:
usage (stderr, argc, argv);
exit (EXIT_FAILURE);
@@ -665,6 +686,8 @@ main (int argc,
start_capturing ();
+ if (framerate > 0) set_framerate(framerate, 1);
+
mainloop (numframes);
stop_capturing ();