The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] media: rkvdec: set ctx->image_fmt in rkvdec_s_capture_fmt
@ 2025-12-12 15:41 Jianfeng Liu
  2025-12-12 16:43 ` Jonas Karlman
  2025-12-12 17:53 ` Nicolas Dufresne
  0 siblings, 2 replies; 6+ messages in thread
From: Jianfeng Liu @ 2025-12-12 15:41 UTC (permalink / raw)
  To: linux-rockchip
  Cc: Nicolas Dufresne, Jonas Karlman, Jianfeng Liu, Detlev Casanova,
	Ezequiel Garcia, Hans Verkuil, Heiko Stuebner,
	Mauro Carvalho Chehab, linux-arm-kernel, linux-kernel,
	linux-media

ctx->image_fmt is initialized as RKVDEC_IMG_FMT_ANY at
rkvdec_s_output_fmt, and get set at rkvdec_s_ctrl when userspace sends
SPS info via VIDIOC_S_EXT_CTRLS. This works fine with gstreamer because
it sends SPS info to kernel driver before requesting capture queue bufs.

But chromium requests capture queue bufs first and then sends SPS info
to kernel, then rkvdec_s_ctrl will return -EBUSY, and the video is
displayed green.

Chromium calls VIDIOC_S_FMT to capture queue instead before requesting
capture queue bufs, so setting ctx->image_fmt in rkvdec_s_capture_fmt
will make rkvdec_s_ctrl return 0 when the first SPS info sent to driver.

Signed-off-by: Jianfeng Liu <liujianfeng1994@gmail.com>
Fixes: d35c64eccf3b1 ("media: rkvdec: Add get_image_fmt ops")
---

 drivers/media/platform/rockchip/rkvdec/rkvdec.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/media/platform/rockchip/rkvdec/rkvdec.c b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
index 5af9aa5ab353..e7939d604f64 100644
--- a/drivers/media/platform/rockchip/rkvdec/rkvdec.c
+++ b/drivers/media/platform/rockchip/rkvdec/rkvdec.c
@@ -537,6 +537,18 @@ static int rkvdec_s_capture_fmt(struct file *file, void *priv,
 		return ret;
 
 	ctx->decoded_fmt = *f;
+
+	u32 fourcc = f->fmt.pix_mp.pixelformat;
+
+	if (fourcc == V4L2_PIX_FMT_NV12)
+		ctx->image_fmt = RKVDEC_IMG_FMT_420_8BIT;
+	else if (fourcc == V4L2_PIX_FMT_NV15)
+		ctx->image_fmt = RKVDEC_IMG_FMT_420_10BIT;
+	else if (fourcc == V4L2_PIX_FMT_NV16)
+		ctx->image_fmt = RKVDEC_IMG_FMT_422_8BIT;
+	else if (fourcc == V4L2_PIX_FMT_NV20)
+		ctx->image_fmt = RKVDEC_IMG_FMT_422_10BIT;
+
 	return 0;
 }
 
-- 
2.43.0


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

end of thread, other threads:[~2025-12-13 14:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-12 15:41 [PATCH] media: rkvdec: set ctx->image_fmt in rkvdec_s_capture_fmt Jianfeng Liu
2025-12-12 16:43 ` Jonas Karlman
2025-12-13  5:50   ` Jianfeng Liu
2025-12-12 17:53 ` Nicolas Dufresne
2025-12-13  5:59   ` Jianfeng Liu
2025-12-13 14:27     ` Nicolas Dufresne

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