summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-07-05 02:20:20 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-10-20 21:28:24 +0200
commite63c0b37164a07c1a944a6597a550472abfeac75 (patch)
treea17be4047442c2bedaa962538ce91c7e6b44d917
parent45b5a7fe12df5b4975cb60629675a0693eb675a6 (diff)
isp: Protect against starting viewfinder and snapshot at the same time
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--isp/omap3isp-priv.h8
-rw-r--r--isp/omap3isp.c12
2 files changed, 20 insertions, 0 deletions
diff --git a/isp/omap3isp-priv.h b/isp/omap3isp-priv.h
index 4e24d31..18babcd 100644
--- a/isp/omap3isp-priv.h
+++ b/isp/omap3isp-priv.h
@@ -150,6 +150,12 @@ struct omap3_isp_pipeline {
struct omap3_isp_resizer resizer;
};
+enum omap3_isp_state {
+ OMAP3_ISP_IDLE,
+ OMAP3_ISP_VIEWFINDER,
+ OMAP3_ISP_SNAPSHOT,
+};
+
struct omap3_isp_device {
struct media_device *mdev;
@@ -174,6 +180,8 @@ struct omap3_isp_device {
struct omap3_isp_pipeline viewfinder;
struct omap3_isp_pipeline snapshot;
+ enum omap3_isp_state state;
+
const struct omap3_isp_operations *ops;
};
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;