media: amphion: reinit vpu if reqbufs output 0

according to v4l2 stateful decoder document 4.5.1.3. State Machine,
the state should change from seek to initialization
if call VIDIOC_REQBUFS(OUTPUT, 0).

so reinit the vpu decoder if reqbufs output 0

Fixes: 6de8d628df ("media: amphion: add v4l2 m2m vpu decoder stateful driver")
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
Ming Qian 2023-06-13 15:48:46 +08:00 committed by Hans Verkuil
parent c62b089163
commit 73e3f09292
2 changed files with 6 additions and 3 deletions
drivers/media/platform/amphion

View File

@ -1453,9 +1453,7 @@ static void vdec_release(struct vpu_inst *inst)
{
if (inst->id != VPU_INST_NULL_ID)
vpu_trace(inst->dev, "[%d]\n", inst->id);
vpu_inst_lock(inst);
vdec_stop(inst, true);
vpu_inst_unlock(inst);
}
static void vdec_cleanup(struct vpu_inst *inst)

View File

@ -489,6 +489,11 @@ static int vpu_vb2_queue_setup(struct vb2_queue *vq,
for (i = 0; i < cur_fmt->mem_planes; i++)
psize[i] = vpu_get_fmt_plane_size(cur_fmt, i);
if (V4L2_TYPE_IS_OUTPUT(vq->type) && inst->state == VPU_CODEC_STATE_SEEK) {
vpu_trace(inst->dev, "reinit when VIDIOC_REQBUFS(OUTPUT, 0)\n");
call_void_vop(inst, release);
}
return 0;
}
@ -773,9 +778,9 @@ int vpu_v4l2_close(struct file *file)
v4l2_m2m_ctx_release(inst->fh.m2m_ctx);
inst->fh.m2m_ctx = NULL;
}
call_void_vop(inst, release);
vpu_inst_unlock(inst);
call_void_vop(inst, release);
vpu_inst_unregister(inst);
vpu_inst_put(inst);