From 594c6519fddcf7c1ecec7a7fea30c96066ec9c4b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 29 Feb 2012 12:20:32 +0100 Subject: omap3isp: Make viewfinder optional Signed-off-by: Laurent Pinchart --- isp/omap3isp.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 9 deletions(-) (limited to 'isp/omap3isp.c') diff --git a/isp/omap3isp.c b/isp/omap3isp.c index f6ec060..9c60f45 100644 --- a/isp/omap3isp.c +++ b/isp/omap3isp.c @@ -381,6 +381,8 @@ static void omap3_isp_pipeline_init(struct omap3_isp_pipeline *pipe) { list_init(&pipe->entities); list_init(&pipe->pools); + + pipe->state = OMAP3_ISP_PIPELINE_STOPPED; } static void omap3_isp_pipeline_destroy(struct omap3_isp_pipeline *pipe) @@ -971,7 +973,7 @@ static void omap3_isp_viewfinder_event(void *priv) isp->ops->viewfinder_ready(isp, &buffer); } -int omap3_isp_viewfinder_start(struct omap3_isp_device *isp) +static int __omap3_isp_viewfinder_start(struct omap3_isp_device *isp) { struct v4l2_video_buffer buffer; struct omap3_isp_pool *pool; @@ -1013,8 +1015,7 @@ int omap3_isp_viewfinder_start(struct omap3_isp_device *isp) return 0; } - -int omap3_isp_viewfinder_stop(struct omap3_isp_device *isp) +static int __omap3_isp_viewfinder_stop(struct omap3_isp_device *isp) { struct omap3_isp_pool *pool; int ret; @@ -1146,6 +1147,64 @@ int omap3_isp_viewfinder_put_buffer(struct omap3_isp_device *isp, return omap3_isp_video_queue_buffer(isp->viewfinder.output, buffer); } +int omap3_isp_viewfinder_start(struct omap3_isp_device *isp) +{ + int ret; + + ret = __omap3_isp_viewfinder_start(isp); + if (ret < 0) + return ret; + + isp->viewfinder.state = OMAP3_ISP_PIPELINE_RUNNING; + return 0; +} + +int omap3_isp_viewfinder_stop(struct omap3_isp_device *isp) +{ + int ret; + + ret = __omap3_isp_viewfinder_stop(isp); + if (ret < 0) + return ret; + + isp->viewfinder.state = OMAP3_ISP_PIPELINE_STOPPED; + return 0; +} + +static int omap3_isp_viewfinder_suspend(struct omap3_isp_device *isp) +{ + int ret; + + if (isp->viewfinder.state != OMAP3_ISP_PIPELINE_RUNNING) + return 0; + + ret = __omap3_isp_viewfinder_stop(isp); + if (ret < 0) + return ret; + + isp->viewfinder.state = OMAP3_ISP_PIPELINE_SUSPENDED; + return 0; +} + +static int omap3_isp_viewfinder_resume(struct omap3_isp_device *isp) +{ + int ret; + + if (isp->viewfinder.state != OMAP3_ISP_PIPELINE_SUSPENDED) + return 0; + + ret = omap3_isp_viewfinder_setup_pipeline(isp); + if (ret < 0) + return ret; + + ret = omap3_isp_viewfinder_start(isp); + if (ret < 0) + return ret; + + isp->viewfinder.state = OMAP3_ISP_PIPELINE_RUNNING; + return 0; +} + /* ----------------------------------------------------------------------------- * Snapshot * @@ -1248,11 +1307,7 @@ static void omap3_isp_snapshot_event(void *priv) isp->ops->snapshot_ready(isp, &buffer); /* Resume the viewfinder. */ - ret = omap3_isp_viewfinder_setup_pipeline(isp); - if (ret < 0) - return; - - ret = omap3_isp_viewfinder_start(isp); + ret = omap3_isp_viewfinder_resume(isp); if (ret < 0) { printf("error: unable to resume viewfinder.\n"); return; @@ -1275,7 +1330,7 @@ int omap3_isp_snapshot_capture(struct omap3_isp_device *isp) int ret; /* Suspend the viewfinder. */ - ret = omap3_isp_viewfinder_stop(isp); + ret = omap3_isp_viewfinder_suspend(isp); if (ret < 0) { printf("error: unable to suspend viewfinder.\n"); return ret; -- cgit v1.2.3