media: vicodec: add support for manual completion

Manually complete the requests: this tests the manual completion
code.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Hans Verkuil
2024-08-29 12:55:38 +02:00
committed by Dom Cobley
parent 7676c4b224
commit 212cfa08ca

View File

@@ -448,8 +448,10 @@ static void device_run(void *priv)
ctx->comp_magic_cnt = 0; ctx->comp_magic_cnt = 0;
ctx->comp_has_frame = false; ctx->comp_has_frame = false;
spin_unlock(ctx->lock); spin_unlock(ctx->lock);
if (ctx->is_stateless && src_req) if (ctx->is_stateless && src_req) {
v4l2_ctrl_request_complete(src_req, &ctx->hdl); v4l2_ctrl_request_complete(src_req, &ctx->hdl);
media_request_manual_complete(src_req);
}
if (ctx->is_enc) if (ctx->is_enc)
v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx); v4l2_m2m_job_finish(dev->stateful_enc.m2m_dev, ctx->fh.m2m_ctx);
@@ -1525,8 +1527,12 @@ static void vicodec_return_bufs(struct vb2_queue *q, u32 state)
vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
if (vbuf == NULL) if (vbuf == NULL)
return; return;
v4l2_ctrl_request_complete(vbuf->vb2_buf.req_obj.req, if (ctx->is_stateless && V4L2_TYPE_IS_OUTPUT(q->type)) {
&ctx->hdl); struct media_request *req = vbuf->vb2_buf.req_obj.req;
v4l2_ctrl_request_complete(req, &ctx->hdl);
media_request_manual_complete(req);
}
spin_lock(ctx->lock); spin_lock(ctx->lock);
v4l2_m2m_buf_done(vbuf, state); v4l2_m2m_buf_done(vbuf, state);
spin_unlock(ctx->lock); spin_unlock(ctx->lock);
@@ -1679,6 +1685,7 @@ static void vicodec_buf_request_complete(struct vb2_buffer *vb)
struct vicodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); struct vicodec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->hdl); v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->hdl);
media_request_manual_complete(vb->req_obj.req);
} }
@@ -2010,6 +2017,12 @@ static int vicodec_request_validate(struct media_request *req)
return vb2_request_validate(req); return vb2_request_validate(req);
} }
static void vicodec_request_queue(struct media_request *req)
{
media_request_mark_manual_completion(req);
v4l2_m2m_request_queue(req);
}
static const struct v4l2_file_operations vicodec_fops = { static const struct v4l2_file_operations vicodec_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = vicodec_open, .open = vicodec_open,
@@ -2030,7 +2043,7 @@ static const struct video_device vicodec_videodev = {
static const struct media_device_ops vicodec_m2m_media_ops = { static const struct media_device_ops vicodec_m2m_media_ops = {
.req_validate = vicodec_request_validate, .req_validate = vicodec_request_validate,
.req_queue = v4l2_m2m_request_queue, .req_queue = vicodec_request_queue,
}; };
static const struct v4l2_m2m_ops m2m_ops = { static const struct v4l2_m2m_ops m2m_ops = {