From e63c0b37164a07c1a944a6597a550472abfeac75 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 5 Jul 2012 02:20:20 +0200 Subject: isp: Protect against starting viewfinder and snapshot at the same time Signed-off-by: Laurent Pinchart --- isp/omap3isp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'isp/omap3isp.c') diff --git a/isp/omap3isp.c b/isp/omap3isp.c index 0c677b4..ed5094c 100644 --- a/isp/omap3isp.c +++ b/isp/omap3isp.c @@ -1001,6 +1001,7 @@ struct omap3_isp_device *omap3_isp_open(const char *devname, return NULL; memset(isp, 0, sizeof *isp); + isp->state = OMAP3_ISP_IDLE; isp->ops = ops; omap3_isp_pipeline_init(&isp->viewfinder); @@ -1217,6 +1218,9 @@ int omap3_isp_viewfinder_start(struct omap3_isp_device *isp, unsigned int bufs) unsigned int i; int ret; + if (isp->state != OMAP3_ISP_IDLE) + return -EBUSY; + /* Setup the pipeline. */ ret = omap3_isp_viewfinder_setup_pipeline(isp); if (ret < 0) @@ -1260,6 +1264,7 @@ int omap3_isp_viewfinder_start(struct omap3_isp_device *isp, unsigned int bufs) } isp->viewfinder.state = OMAP3_ISP_PIPELINE_RUNNING; + isp->state = OMAP3_ISP_VIEWFINDER; return 0; } @@ -1283,6 +1288,7 @@ int omap3_isp_viewfinder_stop(struct omap3_isp_device *isp) omap3_isp_pool_stop(pool); isp->viewfinder.state = OMAP3_ISP_PIPELINE_STOPPED; + isp->state = OMAP3_ISP_IDLE; return 0; } @@ -1387,6 +1393,9 @@ int omap3_isp_snapshot_capture(struct omap3_isp_device *isp) { int ret; + if (isp->state != OMAP3_ISP_IDLE) + return -EBUSY; + /* Configure the pipeline. */ ret = omap3_isp_pipeline_activate(isp, &isp->snapshot); if (ret < 0) { @@ -1410,6 +1419,7 @@ int omap3_isp_snapshot_capture(struct omap3_isp_device *isp) return ret; } + isp->state = OMAP3_ISP_SNAPSHOT; return 0; } @@ -1430,6 +1440,8 @@ int omap3_isp_snapshot_done(struct omap3_isp_device *isp) return ret; } + isp->state = OMAP3_ISP_IDLE; + /* Queue all buffers for the next snapshot. */ for (i = 0; i < isp->snapshot.output->video->nbufs; ++i) { buffer.index = i; -- cgit v1.2.3