summaryrefslogtreecommitdiff
path: root/snapshot.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-02-29 22:40:51 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-04-17 00:12:39 +0200
commitbd4cbd581047b08d8c3d08118229e0d9109d7bff (patch)
tree4edd0add346db027501234360b184349874a0590 /snapshot.c
parent580ffb2d8cec4aed9b0acb5a704408d867cf70cd (diff)
snapshot: Update to the multiple snapshot capture API
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'snapshot.c')
-rw-r--r--snapshot.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/snapshot.c b/snapshot.c
index 3c986a1..7a0302e 100644
--- a/snapshot.c
+++ b/snapshot.c
@@ -121,7 +121,7 @@ static int snapshot_capture(struct omap3_isp_device *isp)
return omap3_isp_snapshot_capture(isp);
}
-static void snapshot_process(struct omap3_isp_device *isp,
+static bool snapshot_process(struct omap3_isp_device *isp,
struct v4l2_video_buffer *buffer)
{
static struct timespec ts;
@@ -131,7 +131,7 @@ static void snapshot_process(struct omap3_isp_device *isp,
if (buffer->error) {
printf("warning: error in dequeued buffer, skipping\n");
- return;
+ return false;
}
ts.tv_sec = buffer->timestamp.tv_sec - snap.time.tv_sec;
@@ -162,15 +162,13 @@ requeue:
if (ret < 0) {
printf("error: unable to requeue buffer: %s (%d)\n",
strerror(-ret), ret);
- return;
+ return false;
}
- if (snap.trigger == SNAPSHOT_TRIGGER_AUTO) {
- if (snap.count < snap.number)
- snapshot_capture(isp);
- else
- events_stop(&events);
- }
+ if (snap.trigger == SNAPSHOT_TRIGGER_AUTO)
+ events_stop(&events);
+
+ return false;
}
static int snapshot_init(struct omap3_isp_device *isp)
@@ -387,6 +385,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
struct omap3_isp_operations ops;
struct timespec start, end;
int exit_code = EXIT_FAILURE;
+ unsigned int i;
float fps;
int ret;
int c;
@@ -478,20 +477,27 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
if (ret < 0)
goto cleanup;
- /* Start the ISP. */
- if (vf.enabled)
+ /* Start the viewfinder if needed. */
+ if (vf.enabled) {
ret = omap3_isp_viewfinder_start(isp);
- else
- ret = snapshot_capture(isp);
-
- if (ret < 0)
- goto cleanup;
+ if (ret < 0)
+ goto cleanup;
+ }
/* Main capture loop. */
clock_gettime(CLOCK_MONOTONIC, &start);
- if (events_loop(&events))
- goto cleanup;
+ for (i = 0; i < snap.number; ++i) {
+ if (!vf.enabled) {
+ printf("- snapshot %u\n", i);
+ ret = snapshot_capture(isp);
+ if (ret < 0)
+ goto cleanup;
+ }
+
+ if (events_loop(&events))
+ goto cleanup;
+ }
clock_gettime(CLOCK_MONOTONIC, &end);
@@ -507,9 +513,11 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
end.tv_nsec += 1000000000;
}
- fps = vf.count / (end.tv_sec + end.tv_nsec / 1000000000.0);
+ fps = (vf.enabled ? vf.count : snap.count)
+ / (end.tv_sec + end.tv_nsec / 1000000000.0);
- printf("%u images processed in %lu.%06lu seconds (%f fps)\n", vf.count,
+ printf("%u images processed in %lu.%06lu seconds (%f fps)\n",
+ vf.enabled ? vf.count : snap.count,
end.tv_sec, end.tv_nsec / 1000, fps);
exit_code = EXIT_SUCCESS;