From: sashiko-bot@kernel.org
To: "Sven Püschel" <s.pueschel@pengutronix.de>
Cc: krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v6 10/28] media: rockchip: rga: announce and sync colorimetry
Date: Fri, 15 May 2026 16:14:13 +0000 [thread overview]
Message-ID: <20260515161416.561C0C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260515-spu-rga3-v6-10-e547152eb9c9@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] Falsely advertising hardware capabilities for CSC quantization and YCbCr encoding.
- [High] Missing validation and clamping of colorimetry fields in `vidioc_try_fmt`.
- [Medium] `vidioc_try_fmt` uses the CAPTURE queue's state instead of the OUTPUT queue's state as the default colorimetry.
- [Medium] `vidioc_try_fmt` accepts user-provided colorimetry for non-YUV formats, bypassing intended restrictions.
- [Low] Comment in `vidioc_enum_fmt` contradicts the implemented code.
--
commit 0b2b6b238c69f747c597a881c5d1349d57e712fe
Author: Sven Püschel <s.pueschel@pengutronix.de>
media: rockchip: rga: announce and sync colorimetry
Announce the capability to adjust the quantization and ycbcr_enc on the
capture side and check if the SET_CSC flag is set when the colorimetry
is changed. Furthermore copy the colorimetry from the output to the
capture side to fix the currently failing v4l2-compliance tests, which
expect exactly this behavior.
> diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
> index ca8d8a53dc251..8c34f73d69764 100644
> --- a/drivers/media/platform/rockchip/rga/rga.c
> +++ b/drivers/media/platform/rockchip/rga/rga.c
> @@ -437,6 +437,15 @@ static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f
> fmt = &formats[f->index];
> f->pixelformat = fmt->fourcc;
>
> + if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
> + f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> + return 0;
> +
> + /* allow changing the quantization and xfer func for YUV formats */
This isn't a bug, but the comment mentions "xfer func" instead of
"ycbcr_enc", while the code sets V4L2_FMT_FLAG_CSC_YCBCR_ENC. Furthermore,
vidioc_try_fmt explicitly disallows modifying xfer_func.
> + if (v4l2_is_format_yuv(v4l2_format_info(f->pixelformat)))
> + f->flags |= V4L2_FMT_FLAG_CSC_QUANTIZATION |
> + V4L2_FMT_FLAG_CSC_YCBCR_ENC;
Does the hardware actually support applying custom quantization and YCbCr
encoding matrices?
Looking at rga_cmd_set_trans_info() in rga-hw.c, the hardware configuration
backend appears to ignore quantization and ycbcr_enc, hardcoding the CSC
mode to either RGA_SRC_CSC_MODE_BT709_R0 or RGA_SRC_CSC_MODE_BT601_R0 based
purely on colorspace.
If the capabilities are announced merely to pass v4l2-compliance without
applying them in hardware, could this cause the driver to silently ignore
user requests and produce visually incorrect output?
[ ... ]
> @@ -459,8 +468,25 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
> static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
> {
> struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
> + struct rga_ctx *ctx = file_to_rga_ctx(file);
> struct rga_fmt *fmt;
>
> + if (V4L2_TYPE_IS_CAPTURE(f->type)) {
> + const struct rga_frame *frm;
> +
> + frm = rga_get_frame(ctx, f->type);
Is it correct to use the CAPTURE queue's state here instead of the OUTPUT
queue's state as the default colorimetry?
For memory-to-memory devices, when V4L2_PIX_FMT_FLAG_SET_CSC is not set on
the CAPTURE queue, it usually falls back to the colorimetry of the OUTPUT
queue (ctx->in). Fetching the frame with f->type resolves to ctx->out for
the CAPTURE queue.
If a user previously used SET_CSC to override the CAPTURE queue's
colorimetry, wouldn't a subsequent call without SET_CSC inherit this
overridden state instead of resetting to the OUTPUT queue's defaults?
> + if (IS_ERR(frm))
> + return PTR_ERR(frm);
> +
> + if (!(pix_fmt->flags & V4L2_PIX_FMT_FLAG_SET_CSC)) {
> + pix_fmt->quantization = frm->pix.quantization;
> + pix_fmt->ycbcr_enc = frm->pix.ycbcr_enc;
> + }
When V4L2_PIX_FMT_FLAG_SET_CSC is set, does this blindly accept
pix_fmt->quantization and pix_fmt->ycbcr_enc without validating if they are
supported enum values?
Additionally, does this enforce the restriction that colorimetry can only
be changed for YUV formats? vidioc_enum_fmt restricts the CSC flags to YUV
formats, but this code seems to honor SET_CSC on the CAPTURE queue
regardless of the format type, allowing arbitrary colorimetry values even
for RGB formats.
Furthermore, for the OUTPUT queue, the colorimetry fields don't seem to be
validated or resolved. Does the driver need to resolve
V4L2_COLORSPACE_DEFAULT to concrete standards and clamp unsupported values
during try_fmt as required by the V4L2 specification?
> + /* disallow values not announced in vidioc_enum_fmt */
> + pix_fmt->colorspace = frm->pix.colorspace;
> + pix_fmt->xfer_func = frm->pix.xfer_func;
> + }
> +
> fmt = rga_fmt_find(pix_fmt->pixelformat);
> if (!fmt)
> fmt = &formats[0];
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260515-spu-rga3-v6-0-e547152eb9c9@pengutronix.de?part=10
next prev parent reply other threads:[~2026-05-15 16:14 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 15:32 [PATCH v6 00/28] media: platform: rga: Add RGA3 support Sven Püschel
2026-05-15 15:32 ` [PATCH v6 01/28] media: dt-bindings: media: rockchip-rga: add rockchip,rk3588-rga3 Sven Püschel
2026-05-15 15:32 ` [PATCH v6 02/28] media: v4l2-common: sort RGB formats in v4l2_format_info Sven Püschel
2026-05-15 15:32 ` [PATCH v6 03/28] media: v4l2-common: add missing 1 and 2 byte RGB formats to v4l2_format_info Sven Püschel
2026-05-15 15:32 ` [PATCH v6 04/28] media: v4l2-common: add has_alpha " Sven Püschel
2026-05-15 15:32 ` [PATCH v6 05/28] media: v4l2-common: add v4l2_fill_pixfmt_mp_aligned helper Sven Püschel
2026-05-15 15:58 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 06/28] media: rockchip: rga: fix too small buffer size Sven Püschel
2026-05-15 15:32 ` [PATCH v6 07/28] media: rockchip: rga: use clk_bulk api Sven Püschel
2026-05-15 15:54 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 08/28] media: rockchip: rga: use stride for offset calculation Sven Püschel
2026-05-15 15:32 ` [PATCH v6 09/28] media: rockchip: rga: remove redundant rga_frame variables Sven Püschel
2026-05-15 15:32 ` [PATCH v6 10/28] media: rockchip: rga: announce and sync colorimetry Sven Püschel
2026-05-15 16:14 ` sashiko-bot [this message]
2026-05-15 15:32 ` [PATCH v6 11/28] media: rockchip: rga: move hw specific parts to a dedicated struct Sven Püschel
2026-05-15 16:05 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 12/28] media: rockchip: rga: avoid odd frame sizes for YUV formats Sven Püschel
2026-05-15 15:32 ` [PATCH v6 13/28] media: rockchip: rga: calculate x_div/y_div using v4l2_format_info Sven Püschel
2026-05-15 15:32 ` [PATCH v6 14/28] media: rockchip: rga: move cmdbuf to rga_ctx Sven Püschel
2026-05-15 16:12 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 15/28] media: rockchip: rga: align stride to 4 bytes Sven Püschel
2026-05-15 16:17 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 16/28] media: rockchip: rga: reuse cmdbuf contents Sven Püschel
2026-05-15 15:59 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 17/28] media: rockchip: rga: check scaling factor Sven Püschel
2026-05-15 16:54 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 18/28] media: rockchip: rga: use card type to specify rga type Sven Püschel
2026-05-15 16:00 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 19/28] media: rockchip: rga: change offset to dma_addresses Sven Püschel
2026-05-15 15:59 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 20/28] media: rockchip: rga: support external iommus Sven Püschel
2026-05-15 16:08 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 21/28] media: rockchip: rga: share the interrupt when an external iommu is used Sven Püschel
2026-05-15 16:11 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 22/28] media: rockchip: rga: remove size from rga_frame Sven Püschel
2026-05-15 16:21 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 23/28] media: rockchip: rga: remove stride " Sven Püschel
2026-05-15 15:32 ` [PATCH v6 24/28] media: rockchip: rga: move rga_fmt to rga-hw.h Sven Püschel
2026-05-15 15:32 ` [PATCH v6 25/28] media: rockchip: rga: add feature flags Sven Püschel
2026-05-15 16:22 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 26/28] media: rockchip: rga: disable multi-core support Sven Püschel
2026-05-15 15:32 ` [PATCH v6 27/28] media: rockchip: rga: add rga3 support Sven Püschel
2026-05-15 16:34 ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 28/28] arm64: dts: rockchip: add rga3 dt nodes Sven Püschel
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=20260515161416.561C0C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=robh@kernel.org \
--cc=s.pueschel@pengutronix.de \
--cc=sashiko-reviews@lists.linux.dev \
/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