media: hantro: Use v4l2_m2m_buf_done_and_job_finish
authorEzequiel Garcia <ezequiel@collabora.com>
Wed, 25 Mar 2020 21:34:34 +0000 (22:34 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 14 Apr 2020 09:22:54 +0000 (11:22 +0200)
Let the core sort out the nuances of returning buffers
to userspace, by using the v4l2_m2m_buf_done_and_job_finish
helper.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/hantro/hantro_drv.c

index ace1397..d0097c5 100644 (file)
@@ -101,8 +101,8 @@ static void hantro_job_finish(struct hantro_dev *vpu,
        pm_runtime_put_autosuspend(vpu->dev);
        clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks);
 
-       src = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
-       dst = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
+       src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
+       dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 
        if (WARN_ON(!src))
                return;
@@ -112,14 +112,14 @@ static void hantro_job_finish(struct hantro_dev *vpu,
        src->sequence = ctx->sequence_out++;
        dst->sequence = ctx->sequence_cap++;
 
-       ret = ctx->buf_finish(ctx, &dst->vb2_buf, bytesused);
-       if (ret)
-               result = VB2_BUF_STATE_ERROR;
-
-       v4l2_m2m_buf_done(src, result);
-       v4l2_m2m_buf_done(dst, result);
+       if (ctx->buf_finish) {
+               ret = ctx->buf_finish(ctx, &dst->vb2_buf, bytesused);
+               if (ret)
+                       result = VB2_BUF_STATE_ERROR;
+       }
 
-       v4l2_m2m_job_finish(vpu->m2m_dev, ctx->fh.m2m_ctx);
+       v4l2_m2m_buf_done_and_job_finish(ctx->dev->m2m_dev, ctx->fh.m2m_ctx,
+                                        result);
 }
 
 void hantro_irq_done(struct hantro_dev *vpu, unsigned int bytesused,