[PATCH 5/7] media: s5p-mfc: support VIDIOC_TRY_DECODER_CMD

From: Shigeaki Asai via B4 Relay

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


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

The stateful decoder interface lets clients check a decoder command
with VIDIOC_TRY_DECODER_CMD, but the driver only implements
VIDIOC_DECODER_CMD, so v4l2-compliance reports:

fail: v4l2-test-codecs.cpp(119): ret == ENOTTY
test VIDIOC_(TRY_)DECODER_CMD: FAIL

Add a try_decoder_cmd handler that accepts V4L2_DEC_CMD_STOP and
V4L2_DEC_CMD_START and clears the fields the driver does not support,
like v4l2_m2m_ioctl_try_decoder_cmd() does for mem2mem drivers. The
driver does not use the mem2mem framework, so that helper cannot be
used directly.

Tested on an ODROID-XU4 (Exynos5422) with Kodi/FFmpeg and
v4l2-compliance 1.32.0 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 281bb733ffa8..99df8f5e36c8 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -853,6 +853,24 @@ static int vidioc_g_selection(struct file *file, void *priv,
return 0;
}

+static int vidioc_try_decoder_cmd(struct file *file, void *priv,
+ struct v4l2_decoder_cmd *cmd)
+{
+ switch (cmd->cmd) {
+ case V4L2_DEC_CMD_STOP:
+ cmd->stop.pts = 0;
+ break;
+ case V4L2_DEC_CMD_START:
+ cmd->start.speed = 0;
+ cmd->start.format = V4L2_DEC_START_FMT_NONE;
+ break;
+ default:
+ return -EINVAL;
+ }
+ cmd->flags = 0;
+ return 0;
+}
+
static int vidioc_decoder_cmd(struct file *file, void *priv,
struct v4l2_decoder_cmd *cmd)
{
@@ -946,6 +964,7 @@ static const struct v4l2_ioctl_ops s5p_mfc_dec_ioctl_ops = {
.vidioc_streamon = vidioc_streamon,
.vidioc_streamoff = vidioc_streamoff,
.vidioc_g_selection = vidioc_g_selection,
+ .vidioc_try_decoder_cmd = vidioc_try_decoder_cmd,
.vidioc_decoder_cmd = vidioc_decoder_cmd,
.vidioc_subscribe_event = vidioc_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,

--
2.43.0