Commit 5c718bb3 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

[media] coda: avoid calling SEQ_END twice

Allow coda_seq_end_work to be called multiple times, move the setting
of ctx->initialized from coda_start/stop_streaming() into
coda_start_encoding/decoding and coda_seq_end_work, respectively,
and skip the SEQ_END command in coda_seq_end_work if the context is
already deinitialized before.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 30a09579
...@@ -999,6 +999,7 @@ static int coda_start_encoding(struct coda_ctx *ctx) ...@@ -999,6 +999,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
ctx->initialized = 1;
if (dst_fourcc != V4L2_PIX_FMT_JPEG) { if (dst_fourcc != V4L2_PIX_FMT_JPEG) {
if (dev->devtype->product == CODA_960) if (dev->devtype->product == CODA_960)
...@@ -1329,6 +1330,9 @@ static void coda_seq_end_work(struct work_struct *work) ...@@ -1329,6 +1330,9 @@ static void coda_seq_end_work(struct work_struct *work)
mutex_lock(&ctx->buffer_mutex); mutex_lock(&ctx->buffer_mutex);
mutex_lock(&dev->coda_mutex); mutex_lock(&dev->coda_mutex);
if (ctx->initialized == 0)
goto out;
v4l2_dbg(1, coda_debug, &dev->v4l2_dev, v4l2_dbg(1, coda_debug, &dev->v4l2_dev,
"%d: %s: sent command 'SEQ_END' to coda\n", ctx->idx, "%d: %s: sent command 'SEQ_END' to coda\n", ctx->idx,
__func__); __func__);
...@@ -1342,6 +1346,9 @@ static void coda_seq_end_work(struct work_struct *work) ...@@ -1342,6 +1346,9 @@ static void coda_seq_end_work(struct work_struct *work)
coda_free_framebuffers(ctx); coda_free_framebuffers(ctx);
ctx->initialized = 0;
out:
mutex_unlock(&dev->coda_mutex); mutex_unlock(&dev->coda_mutex);
mutex_unlock(&ctx->buffer_mutex); mutex_unlock(&ctx->buffer_mutex);
} }
...@@ -1499,6 +1506,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx) ...@@ -1499,6 +1506,7 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
coda_write(dev, 0, CODA_REG_BIT_BIT_STREAM_PARAM); coda_write(dev, 0, CODA_REG_BIT_BIT_STREAM_PARAM);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
ctx->initialized = 1;
/* Update kfifo out pointer from coda bitstream read pointer */ /* Update kfifo out pointer from coda bitstream read pointer */
coda_kfifo_sync_from_device(ctx); coda_kfifo_sync_from_device(ctx);
......
...@@ -1313,7 +1313,6 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) ...@@ -1313,7 +1313,6 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
goto err; goto err;
} }
ctx->initialized = 1;
return ret; return ret;
err: err:
...@@ -1376,7 +1375,6 @@ static void coda_stop_streaming(struct vb2_queue *q) ...@@ -1376,7 +1375,6 @@ static void coda_stop_streaming(struct vb2_queue *q)
mutex_unlock(&ctx->bitstream_mutex); mutex_unlock(&ctx->bitstream_mutex);
kfifo_init(&ctx->bitstream_fifo, kfifo_init(&ctx->bitstream_fifo,
ctx->bitstream.vaddr, ctx->bitstream.size); ctx->bitstream.vaddr, ctx->bitstream.size);
ctx->initialized = 0;
ctx->runcounter = 0; ctx->runcounter = 0;
ctx->aborting = 0; ctx->aborting = 0;
} }
...@@ -1767,7 +1765,7 @@ static int coda_release(struct file *file) ...@@ -1767,7 +1765,7 @@ static int coda_release(struct file *file)
v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
/* In case the instance was not running, we still need to call SEQ_END */ /* In case the instance was not running, we still need to call SEQ_END */
if (ctx->initialized && ctx->ops->seq_end_work) { if (ctx->ops->seq_end_work) {
queue_work(dev->workqueue, &ctx->seq_end_work); queue_work(dev->workqueue, &ctx->seq_end_work);
flush_work(&ctx->seq_end_work); flush_work(&ctx->seq_end_work);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment