From 45b5a7fe12df5b4975cb60629675a0693eb675a6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 5 Jul 2012 02:49:17 +0200 Subject: live, snapshot: Split the viewfinder and snapshot API Signed-off-by: Laurent Pinchart --- live.c | 2 +- snapshot.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/live.c b/live.c index 8ae386c..97a4e12 100644 --- a/live.c +++ b/live.c @@ -714,7 +714,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu } /* Start the ISP. */ - ret = omap3_isp_viewfinder_start(isp); + ret = omap3_isp_viewfinder_start(isp, -1); if (ret < 0) goto cleanup; diff --git a/snapshot.c b/snapshot.c index c8b0b27..878d4bf 100644 --- a/snapshot.c +++ b/snapshot.c @@ -155,7 +155,7 @@ static int snapshot_capture(struct omap3_isp_device *isp) return omap3_isp_snapshot_capture(isp); } -static bool snapshot_process(struct omap3_isp_device *isp, +static void snapshot_process(struct omap3_isp_device *isp, struct v4l2_video_buffer *buffer) { static struct timespec ts; @@ -204,20 +204,29 @@ requeue: if (ret < 0) { printf("error: unable to requeue buffer: %s (%d)\n", strerror(-ret), ret); - return false; + return; } if (buffer->error) - return true; + return; snap.frame++; if (snap.frame < snap.nframes) - return true; + return; if (snap.trigger == SNAPSHOT_TRIGGER_AUTO) events_stop(&events); - return false; + omap3_isp_snapshot_done(isp); + + if (vf.enabled) { + ret = omap3_isp_viewfinder_start(isp, -1); + if (ret < 0) { + printf("error: unable to restart viewfinder: %s (%d)\n", + strerror(-ret), ret); + return; + } + } } static int snapshot_init(struct omap3_isp_device *isp) @@ -277,9 +286,6 @@ static void viewfinder_process(struct omap3_isp_device *isp, vf.count++; printf("viewfinder frame %u captured.\n", vf.count); - if ((vf.count % snap.interval) == 0) - snapshot_capture(isp); - /* Requeue the buffer */ ret = omap3_isp_viewfinder_put_buffer(isp, buffer); if (ret < 0) { @@ -287,6 +293,17 @@ static void viewfinder_process(struct omap3_isp_device *isp, strerror(-ret), ret); return; } + + if ((vf.count % snap.interval) == 0) { + ret = omap3_isp_viewfinder_stop(isp); + if (ret < 0) { + printf("error: unable to stop viewfinder: %s (%d)\n", + strerror(-ret), ret); + return; + } + + snapshot_capture(isp); + } } static int viewfinder_init(struct omap3_isp_device *isp) @@ -627,7 +644,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu /* Start the viewfinder if needed. */ if (vf.enabled) { - ret = omap3_isp_viewfinder_start(isp); + ret = omap3_isp_viewfinder_start(isp, -1); if (ret < 0) goto cleanup; } -- cgit v1.2.3