Commit 497e6b85 authored by Philipp Zabel's avatar Philipp Zabel Committed by Mauro Carvalho Chehab

media: coda: add sequence initialization work

Add a sequence initialization work item to be run when OUTPUT buffers
are queued in the initialization state.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 8e717396
...@@ -1824,6 +1824,30 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx) ...@@ -1824,6 +1824,30 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)
return 0; return 0;
} }
static void coda_dec_seq_init_work(struct work_struct *work)
{
struct coda_ctx *ctx = container_of(work,
struct coda_ctx, seq_init_work);
struct coda_dev *dev = ctx->dev;
int ret;
mutex_lock(&ctx->buffer_mutex);
mutex_lock(&dev->coda_mutex);
if (ctx->initialized == 1)
goto out;
ret = __coda_decoder_seq_init(ctx);
if (ret < 0)
goto out;
ctx->initialized = 1;
out:
mutex_unlock(&dev->coda_mutex);
mutex_unlock(&ctx->buffer_mutex);
}
static int __coda_start_decoding(struct coda_ctx *ctx) static int __coda_start_decoding(struct coda_ctx *ctx)
{ {
struct coda_q_data *q_data_src, *q_data_dst; struct coda_q_data *q_data_src, *q_data_dst;
...@@ -2352,6 +2376,7 @@ const struct coda_context_ops coda_bit_decode_ops = { ...@@ -2352,6 +2376,7 @@ const struct coda_context_ops coda_bit_decode_ops = {
.prepare_run = coda_prepare_decode, .prepare_run = coda_prepare_decode,
.finish_run = coda_finish_decode, .finish_run = coda_finish_decode,
.run_timeout = coda_decode_timeout, .run_timeout = coda_decode_timeout,
.seq_init_work = coda_dec_seq_init_work,
.seq_end_work = coda_seq_end_work, .seq_end_work = coda_seq_end_work,
.release = coda_bit_release, .release = coda_bit_release,
}; };
......
...@@ -1684,6 +1684,19 @@ static void coda_buf_queue(struct vb2_buffer *vb) ...@@ -1684,6 +1684,19 @@ static void coda_buf_queue(struct vb2_buffer *vb)
/* This set buf->sequence = ctx->qsequence++ */ /* This set buf->sequence = ctx->qsequence++ */
coda_fill_bitstream(ctx, NULL); coda_fill_bitstream(ctx, NULL);
mutex_unlock(&ctx->bitstream_mutex); mutex_unlock(&ctx->bitstream_mutex);
if (!ctx->initialized) {
/*
* Run sequence initialization in case the queued
* buffer contained headers.
*/
if (vb2_is_streaming(vb->vb2_queue) &&
ctx->ops->seq_init_work) {
queue_work(ctx->dev->workqueue,
&ctx->seq_init_work);
flush_work(&ctx->seq_init_work);
}
}
} else { } else {
if (ctx->inst_type == CODA_INST_ENCODER && if (ctx->inst_type == CODA_INST_ENCODER &&
vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
...@@ -1761,6 +1774,15 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) ...@@ -1761,6 +1774,15 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
if (!ctx->initialized) {
/* Run sequence initialization */
if (ctx->ops->seq_init_work) {
queue_work(ctx->dev->workqueue,
&ctx->seq_init_work);
flush_work(&ctx->seq_init_work);
}
}
} }
ctx->streamon_out = 1; ctx->streamon_out = 1;
...@@ -2317,6 +2339,8 @@ static int coda_open(struct file *file) ...@@ -2317,6 +2339,8 @@ static int coda_open(struct file *file)
ctx->use_bit = !ctx->cvd->direct; ctx->use_bit = !ctx->cvd->direct;
init_completion(&ctx->completion); init_completion(&ctx->completion);
INIT_WORK(&ctx->pic_run_work, coda_pic_run_work); INIT_WORK(&ctx->pic_run_work, coda_pic_run_work);
if (ctx->ops->seq_init_work)
INIT_WORK(&ctx->seq_init_work, ctx->ops->seq_init_work);
if (ctx->ops->seq_end_work) if (ctx->ops->seq_end_work)
INIT_WORK(&ctx->seq_end_work, ctx->ops->seq_end_work); INIT_WORK(&ctx->seq_end_work, ctx->ops->seq_end_work);
v4l2_fh_init(&ctx->fh, video_devdata(file)); v4l2_fh_init(&ctx->fh, video_devdata(file));
......
...@@ -185,6 +185,7 @@ struct coda_context_ops { ...@@ -185,6 +185,7 @@ struct coda_context_ops {
int (*prepare_run)(struct coda_ctx *ctx); int (*prepare_run)(struct coda_ctx *ctx);
void (*finish_run)(struct coda_ctx *ctx); void (*finish_run)(struct coda_ctx *ctx);
void (*run_timeout)(struct coda_ctx *ctx); void (*run_timeout)(struct coda_ctx *ctx);
void (*seq_init_work)(struct work_struct *work);
void (*seq_end_work)(struct work_struct *work); void (*seq_end_work)(struct work_struct *work);
void (*release)(struct coda_ctx *ctx); void (*release)(struct coda_ctx *ctx);
}; };
...@@ -193,6 +194,7 @@ struct coda_ctx { ...@@ -193,6 +194,7 @@ struct coda_ctx {
struct coda_dev *dev; struct coda_dev *dev;
struct mutex buffer_mutex; struct mutex buffer_mutex;
struct work_struct pic_run_work; struct work_struct pic_run_work;
struct work_struct seq_init_work;
struct work_struct seq_end_work; struct work_struct seq_end_work;
struct completion completion; struct completion completion;
const struct coda_video_device *cvd; const struct coda_video_device *cvd;
......
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