[PATCH 2/7] media: s5p-mfc: support V4L2_DEC_CMD_START

From: Shigeaki Asai via B4 Relay

Date: Mon Nov 30 2026 - 08:05:40 EST


From: Shigeaki Asai <y-asai.0816@xxxxxxxxxxxx>

The stateful decoder interface requires V4L2_DEC_CMD_START to resume
decoding after a drain, but the driver only implements
V4L2_DEC_CMD_STOP and returns -EINVAL for START. Clients such as
FFmpeg issue START after a seek, so the capture queue stays in the
"last buffer dequeued" state and decoding does not resume.

Implement START the same way as restarting the capture queue: put the
instance back into the running state, clear the last buffer state of
the capture queue and schedule the context if it is ready. If the
CAPTURE queue is not streaming, return 0 without doing anything, as
the specification says that the command does not fail in that case.

Tested on an ODROID-XU4 (Exynos5422) with Kodi/FFmpeg on a 7.3.4
kernel (LibreELEC).

The problem was investigated and this patch was prepared with the help
of Claude (AI).

Signed-off-by: Shigeaki Asai <y-asai.0816@xxxxxxxxxxxx>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
index 1b6ea99bd415..b46ccc0d9f3d 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -888,6 +888,25 @@ static int vidioc_decoder_cmd(struct file *file, void *priv,
spin_unlock_irqrestore(&dev->irqlock, flags);
}
break;
+ case V4L2_DEC_CMD_START:
+ if (cmd->flags != 0)
+ return -EINVAL;
+
+ if (!vb2_is_streaming(&ctx->vq_dst))
+ return 0;
+
+ spin_lock_irqsave(&dev->irqlock, flags);
+ if (ctx->state == MFCINST_FINISHING ||
+ ctx->state == MFCINST_FINISHED)
+ ctx->state = MFCINST_RUNNING;
+ spin_unlock_irqrestore(&dev->irqlock, flags);
+
+ vb2_clear_last_buffer_dequeued(&ctx->vq_dst);
+
+ if (s5p_mfc_ctx_ready(ctx))
+ set_work_bit_irqsave(ctx);
+ s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
+ break;
default:
return -EINVAL;
}

--
2.43.0