From: Jonas Karlman <jonas@kwiboo.se>
To: Jianfeng Liu <liujianfeng1994@gmail.com>
Cc: linux-rockchip@lists.infradead.org,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Detlev Casanova <detlev.casanova@collabora.com>,
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
Hans Verkuil <hverkuil@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: Re: [PATCH] media: rkvdec: set ctx->image_fmt in rkvdec_s_capture_fmt
Date: Fri, 12 Dec 2025 17:43:35 +0100 [thread overview]
Message-ID: <5c2dec91-667f-48f6-b958-e0cf81cab569@kwiboo.se> (raw)
In-Reply-To: <20251212154138.3042300-1-liujianfeng1994@gmail.com>
Hi,
On 12/12/2025 4:41 PM, Jianfeng Liu wrote:
> 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;
ctx->image_fmt is used to limit what CAPTURE pixel format can be set and
forcing it here violates this.
Chromium should be fixed to follow spec at 4.5.3.2. Initialization [1]:
1. Set the coded format on the OUTPUT queue via VIDIOC_S_FMT().
2. Call VIDIOC_S_EXT_CTRLS() to set all the controls (parsed headers,
etc.) required by the OUTPUT format to enumerate the CAPTURE formats.
...
5. [optional] Choose a different CAPTURE format than suggested via
VIDIOC_S_FMT() on CAPTURE queue.
Regards,
Jonas
[1] https://docs.kernel.org/userspace-api/media/v4l/dev-stateless-decoder.html
> +
> return 0;
> }
>
next prev parent reply other threads:[~2025-12-12 16:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-12 15:41 Jianfeng Liu
2025-12-12 16:43 ` Jonas Karlman [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5c2dec91-667f-48f6-b958-e0cf81cab569@kwiboo.se \
--to=jonas@kwiboo.se \
--cc=detlev.casanova@collabora.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=heiko@sntech.de \
--cc=hverkuil@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=liujianfeng1994@gmail.com \
--cc=mchehab@kernel.org \
--cc=nicolas.dufresne@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®