aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2012-07-25 09:40:39 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-26 15:54:13 -0400
commit62bed14c4f634b706227098c31c3755ed40204f7 (patch)
treeffc4fc56d533209982e795b5eac598057e151d8b /drivers/media/platform
parent09ae956f9389ad49408d5db4f296e48a26fd4207 (diff)
[media] media: coda: wait for picture run completion in start/stop_streaming
While the CODA is running a PIC_RUN command, its registers are not to be touched. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Tested-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r--drivers/media/platform/coda.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index b80c79af0733..0c55d67f8ac3 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -137,6 +137,7 @@ struct coda_dev {
137 struct list_head instances; 137 struct list_head instances;
138 unsigned long instance_mask; 138 unsigned long instance_mask;
139 struct delayed_work timeout; 139 struct delayed_work timeout;
140 struct completion done;
140}; 141};
141 142
142struct coda_params { 143struct coda_params {
@@ -731,6 +732,7 @@ static void coda_device_run(void *m2m_priv)
731 /* 1 second timeout in case CODA locks up */ 732 /* 1 second timeout in case CODA locks up */
732 schedule_delayed_work(&dev->timeout, HZ); 733 schedule_delayed_work(&dev->timeout, HZ);
733 734
735 INIT_COMPLETION(dev->done);
734 coda_command_async(ctx, CODA_COMMAND_PIC_RUN); 736 coda_command_async(ctx, CODA_COMMAND_PIC_RUN);
735} 737}
736 738
@@ -975,6 +977,10 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
975 if (!(ctx->rawstreamon & ctx->compstreamon)) 977 if (!(ctx->rawstreamon & ctx->compstreamon))
976 return 0; 978 return 0;
977 979
980 if (coda_isbusy(dev))
981 if (wait_for_completion_interruptible_timeout(&dev->done, HZ) <= 0)
982 return -EBUSY;
983
978 ctx->gopcounter = ctx->params.gop_size - 1; 984 ctx->gopcounter = ctx->params.gop_size - 1;
979 985
980 q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT); 986 q_data_src = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
@@ -1229,20 +1235,29 @@ static int coda_stop_streaming(struct vb2_queue *q)
1229 ctx->compstreamon = 0; 1235 ctx->compstreamon = 0;
1230 } 1236 }
1231 1237
1232 if (!ctx->rawstreamon && !ctx->compstreamon) { 1238 /* Don't stop the coda unless both queues are off */
1233 cancel_delayed_work(&dev->timeout); 1239 if (ctx->rawstreamon || ctx->compstreamon)
1240 return 0;
1234 1241
1235 v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, 1242 if (coda_isbusy(dev)) {
1236 "%s: sent command 'SEQ_END' to coda\n", __func__); 1243 if (wait_for_completion_interruptible_timeout(&dev->done, HZ) <= 0) {
1237 if (coda_command_sync(ctx, CODA_COMMAND_SEQ_END)) { 1244 v4l2_warn(&dev->v4l2_dev,
1238 v4l2_err(&ctx->dev->v4l2_dev, 1245 "%s: timeout, sending SEQ_END anyway\n", __func__);
1239 "CODA_COMMAND_SEQ_END failed\n");
1240 return -ETIMEDOUT;
1241 } 1246 }
1247 }
1248
1249 cancel_delayed_work(&dev->timeout);
1242 1250
1243 coda_free_framebuffers(ctx); 1251 v4l2_dbg(1, coda_debug, &dev->v4l2_dev,
1252 "%s: sent command 'SEQ_END' to coda\n", __func__);
1253 if (coda_command_sync(ctx, CODA_COMMAND_SEQ_END)) {
1254 v4l2_err(&dev->v4l2_dev,
1255 "CODA_COMMAND_SEQ_END failed\n");
1256 return -ETIMEDOUT;
1244 } 1257 }
1245 1258
1259 coda_free_framebuffers(ctx);
1260
1246 return 0; 1261 return 0;
1247} 1262}
1248 1263
@@ -1527,6 +1542,8 @@ static irqreturn_t coda_irq_handler(int irq, void *data)
1527 return IRQ_NONE; 1542 return IRQ_NONE;
1528 } 1543 }
1529 1544
1545 complete(&dev->done);
1546
1530 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx); 1547 src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
1531 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx); 1548 dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
1532 1549
@@ -1582,6 +1599,11 @@ static void coda_timeout(struct work_struct *work)
1582 struct coda_dev *dev = container_of(to_delayed_work(work), 1599 struct coda_dev *dev = container_of(to_delayed_work(work),
1583 struct coda_dev, timeout); 1600 struct coda_dev, timeout);
1584 1601
1602 if (completion_done(&dev->done))
1603 return;
1604
1605 complete(&dev->done);
1606
1585 v4l2_err(&dev->v4l2_dev, "CODA PIC_RUN timeout, stopping all streams\n"); 1607 v4l2_err(&dev->v4l2_dev, "CODA PIC_RUN timeout, stopping all streams\n");
1586 1608
1587 mutex_lock(&dev->dev_mutex); 1609 mutex_lock(&dev->dev_mutex);
@@ -1865,6 +1887,8 @@ static int __devinit coda_probe(struct platform_device *pdev)
1865 spin_lock_init(&dev->irqlock); 1887 spin_lock_init(&dev->irqlock);
1866 INIT_LIST_HEAD(&dev->instances); 1888 INIT_LIST_HEAD(&dev->instances);
1867 INIT_DELAYED_WORK(&dev->timeout, coda_timeout); 1889 INIT_DELAYED_WORK(&dev->timeout, coda_timeout);
1890 init_completion(&dev->done);
1891 complete(&dev->done);
1868 1892
1869 dev->plat_dev = pdev; 1893 dev->plat_dev = pdev;
1870 dev->clk_per = devm_clk_get(&pdev->dev, "per"); 1894 dev->clk_per = devm_clk_get(&pdev->dev, "per");