mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: amphion: Start decoding job when both queue are on
@ 2024-07-19  7:50 Ming Qian
  2024-07-19  7:50 ` [PATCH] media: amphion: Add H264 and HEVC profile and level control Ming Qian
  2025-04-22 19:46 ` [PATCH] media: amphion: Start decoding job when both queue are on Nicolas Dufresne
  0 siblings, 2 replies; 4+ messages in thread
From: Ming Qian @ 2024-07-19  7:50 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco
  Cc: nicolas, shawnguo, robh+dt, s.hauer, kernel, festevam, linux-imx,
	xiahong.bao, eagle.zhou, tao.jiang_2, ming.qian, imx,
	linux-media, linux-kernel, linux-arm-kernel

Start the decoding job when both queue are on, except the for the
initialization sequence.

Especially when seeking, the capture streamon may be called after output
streamon, driver will start to decode job immediately after output
streamo, if seek to a new resolution, then the source change flow may be
mixed with the seek, it will cause confusion, then may led to pipeline
hang.

When both output and capture queue are on, it's ready to start the
decoding job, and it can avoid the above potential problem.

Signed-off-by: Ming Qian <ming.qian@nxp.com>
---
 drivers/media/platform/amphion/vdec.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c
index 6a38a0fa0e2d..ca8f7319503a 100644
--- a/drivers/media/platform/amphion/vdec.c
+++ b/drivers/media/platform/amphion/vdec.c
@@ -1363,6 +1363,12 @@ static int vdec_process_output(struct vpu_inst *inst, struct vb2_buffer *vb)
 	if (inst->state == VPU_CODEC_STATE_STARTED)
 		vdec_update_state(inst, VPU_CODEC_STATE_ACTIVE, 0);
 
+	if (vdec->seq_hdr_found &&
+	    !vb2_start_streaming_called((v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx)))) {
+		vpu_trace(inst->dev, "[%d] capture is not ready, pend input frame\n", inst->id);
+		return -EINVAL;
+	}
+
 	ret = vpu_iface_get_stream_buffer_desc(inst, &desc);
 	if (ret)
 		return ret;
@@ -1555,6 +1561,16 @@ static int vdec_start(struct vpu_inst *inst)
 	return ret;
 }
 
+static void vdec_enqueue_pending_frames(struct vpu_inst *inst)
+{
+	int i;
+
+	for (i = 0; i < v4l2_m2m_num_src_bufs_ready(inst->fh.m2m_ctx); i++) {
+		if (vpu_process_output_buffer(inst))
+			break;
+	}
+}
+
 static int vdec_start_session(struct vpu_inst *inst, u32 type)
 {
 	struct vdec_t *vdec = inst->priv;
@@ -1573,10 +1589,10 @@ static int vdec_start_session(struct vpu_inst *inst, u32 type)
 	if (V4L2_TYPE_IS_OUTPUT(type)) {
 		vdec_update_state(inst, vdec->state, 1);
 		vdec->eos_received = 0;
-		vpu_process_output_buffer(inst);
 	} else {
 		vdec_cmd_start(inst);
 	}
+	vdec_enqueue_pending_frames(inst);
 	if (inst->state == VPU_CODEC_STATE_ACTIVE)
 		vdec_response_fs_request(inst, false);
 
-- 
2.43.0-rc1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-25  2:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-19  7:50 [PATCH] media: amphion: Start decoding job when both queue are on Ming Qian
2024-07-19  7:50 ` [PATCH] media: amphion: Add H264 and HEVC profile and level control Ming Qian
2025-04-22 19:46 ` [PATCH] media: amphion: Start decoding job when both queue are on Nicolas Dufresne
2025-04-25  2:51   ` Ming Qian(OSS)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®