From 580ffb2d8cec4aed9b0acb5a704408d867cf70cd Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 29 Feb 2012 22:17:31 +0100 Subject: omap3isp: Support capture of multiple snapshots Signed-off-by: Laurent Pinchart --- isp/omap3isp.c | 56 ++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 20 deletions(-) (limited to 'isp/omap3isp.c') diff --git a/isp/omap3isp.c b/isp/omap3isp.c index 9c60f45..bffbe13 100644 --- a/isp/omap3isp.c +++ b/isp/omap3isp.c @@ -852,6 +852,22 @@ static int omap3_isp_pipeline_activate(struct omap3_isp_device *isp, return 0; } +static int omap3_isp_pipeline_put_buffer(struct omap3_isp_device *isp, + struct omap3_isp_pipeline *pipe, + void(*callback)(void*), + struct v4l2_video_buffer *buffer) +{ + pipe->output->dequeued &= ~(1 << buffer->index); + + if (!pipe->output->running) + return 0; + + if (pipe->output->queued == 0) + isp->ops->watch_fd(pipe->output->video->fd, + OMAP3_ISP_EVENT_READ, callback, isp); + + return omap3_isp_video_queue_buffer(pipe->output, buffer); +} /* ----------------------------------------------------------------------------- * Open/close */ @@ -1134,17 +1150,9 @@ int omap3_isp_viewfinder_set_scaler(struct omap3_isp_device *isp, int omap3_isp_viewfinder_put_buffer(struct omap3_isp_device *isp, struct v4l2_video_buffer *buffer) { - isp->viewfinder.output->dequeued &= ~(1 << buffer->index); - - if (!isp->viewfinder.output->running) - return 0; - - if (isp->viewfinder.output->queued == 0) - isp->ops->watch_fd(isp->viewfinder.output->video->fd, - OMAP3_ISP_EVENT_READ, - omap3_isp_viewfinder_event, isp); - - return omap3_isp_video_queue_buffer(isp->viewfinder.output, buffer); + return omap3_isp_pipeline_put_buffer(isp, &isp->viewfinder, + omap3_isp_viewfinder_event, + buffer); } int omap3_isp_viewfinder_start(struct omap3_isp_device *isp) @@ -1287,6 +1295,7 @@ static void omap3_isp_snapshot_event(void *priv) struct omap3_isp_device *isp = priv; struct v4l2_video_buffer buffer; unsigned int i; + bool again; int ret; /* Dequeue a buffer, stop the stream and fire the snapshot event. */ @@ -1296,6 +1305,18 @@ static void omap3_isp_snapshot_event(void *priv) return; } + again = isp->ops->snapshot_ready(isp, &buffer); + + if (again) { + isp->snapshot.output->dequeued |= 1 << buffer.index; + + if (isp->snapshot.output->queued == 0) + isp->ops->unwatch_fd(isp->snapshot.output->video->fd); + + return; + } + + /* We're done, stop the stream and resume the viewfinder. */ isp->ops->unwatch_fd(isp->snapshot.output->video->fd); ret = omap3_isp_video_stop(isp->snapshot.output); @@ -1304,9 +1325,6 @@ static void omap3_isp_snapshot_event(void *priv) return; } - isp->ops->snapshot_ready(isp, &buffer); - - /* Resume the viewfinder. */ ret = omap3_isp_viewfinder_resume(isp); if (ret < 0) { printf("error: unable to resume viewfinder.\n"); @@ -1359,11 +1377,9 @@ int omap3_isp_snapshot_capture(struct omap3_isp_device *isp) return 0; } -int omap3_isp_snapshot_put_buffer(struct omap3_isp_device *isp __attribute__((__unused__)), - struct v4l2_video_buffer *buffer __attribute__((__unused__))) +int omap3_isp_snapshot_put_buffer(struct omap3_isp_device *isp, + struct v4l2_video_buffer *buffer) { - /* No-op, the stream is already stopped so we don't need to requeue the - * buffer. - */ - return 0; + return omap3_isp_pipeline_put_buffer(isp, &isp->snapshot, + omap3_isp_snapshot_event, buffer); } -- cgit v1.2.3