From nobody Fri Apr 3 03:00:11 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B5673FE65F for ; Wed, 25 Mar 2026 14:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774450278; cv=none; b=b+3DGox+htKEYvurdzCR7mi3P9L5NAmXrWKhTzRDxIj48ZEekr/C9jKtx+cYtJq9RfLmu1nv6QcfVtWHYUHoMj16VA75xfIqz1Q4jaiNLeg31AI4NyfDZNRLpTLKQMPL7DvhkoH+UGViPkNKp9cZoQTHTYrckCOLANsd1+YXuoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774450278; c=relaxed/simple; bh=gPbM2ntWEVJKb5duLxVXP5Frg6guvtbDlPli/HqhZRs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nrUSTz/ZREqXUKftM3XjOgk/mnVz0ruEIOVumahgPYVdOf4ME+Hu/LzJe7ZzjiWpQvZKfmSOmVliviB9O9vYOQYyDqVfkG/3XBnqRKNAM6/ZBOiwAsTa+DiaSf6fqcJfCqPb232TciGhX8VIWUvsnUpsanBv08HrJSd+0SLgnN0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=peter.mobile.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1w5PZT-00050C-Nz; Wed, 25 Mar 2026 15:50:59 +0100 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Wed, 25 Mar 2026 15:50:40 +0100 Subject: [PATCH v4 09/27] media: rockchip: rga: announce and sync colorimetry Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260325-spu-rga3-v4-9-e90ec1c61354@pengutronix.de> References: <20260325-spu-rga3-v4-0-e90ec1c61354@pengutronix.de> In-Reply-To: <20260325-spu-rga3-v4-0-e90ec1c61354@pengutronix.de> To: Jacob Chen , Ezequiel Garcia , Mauro Carvalho Chehab , Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de, nicolas@ndufresne.ca, sebastian.reichel@collabora.com, =?utf-8?q?Sven_P=C3=BCschel?= , Nicolas Dufresne X-Mailer: b4 0.15.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: s.pueschel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org 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. Reviewed-by: Nicolas Dufresne Signed-off-by: Sven P=C3=BCschel --- drivers/media/platform/rockchip/rga/rga.c | 37 +++++++++++++++++++++++++++= ++++ 1 file changed, 37 insertions(+) diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/plat= form/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 *pr= iv, struct v4l2_fmtdesc *f fmt =3D &formats[f->index]; f->pixelformat =3D fmt->fourcc; =20 + if (f->type !=3D V4L2_BUF_TYPE_VIDEO_CAPTURE && + f->type !=3D V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + return 0; + + /* allow changing the quantization and xfer func for YUV formats */ + if (v4l2_is_format_yuv(v4l2_format_info(f->pixelformat))) + f->flags |=3D V4L2_FMT_FLAG_CSC_QUANTIZATION | + V4L2_FMT_FLAG_CSC_YCBCR_ENC; + return 0; } =20 @@ -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_forma= t *f) { struct v4l2_pix_format_mplane *pix_fmt =3D &f->fmt.pix_mp; + struct rga_ctx *ctx =3D file_to_rga_ctx(file); struct rga_fmt *fmt; =20 + if (V4L2_TYPE_IS_CAPTURE(f->type)) { + const struct rga_frame *frm; + + frm =3D rga_get_frame(ctx, f->type); + if (IS_ERR(frm)) + return PTR_ERR(frm); + + if (!(pix_fmt->flags & V4L2_PIX_FMT_FLAG_SET_CSC)) { + pix_fmt->quantization =3D frm->pix.quantization; + pix_fmt->ycbcr_enc =3D frm->pix.ycbcr_enc; + } + /* disallow values not announced in vidioc_enum_fmt */ + pix_fmt->colorspace =3D frm->pix.colorspace; + pix_fmt->xfer_func =3D frm->pix.xfer_func; + } + fmt =3D rga_fmt_find(pix_fmt->pixelformat); if (!fmt) fmt =3D &formats[0]; @@ -506,6 +532,17 @@ static int vidioc_s_fmt(struct file *file, void *priv,= struct v4l2_format *f) frm->fmt =3D rga_fmt_find(pix_fmt->pixelformat); frm->stride =3D pix_fmt->plane_fmt[0].bytesperline; =20 + /* + * Copy colorimetry from output to capture as required by the + * v4l2-compliance tests + */ + if (V4L2_TYPE_IS_OUTPUT(f->type)) { + ctx->out.pix.colorspace =3D pix_fmt->colorspace; + ctx->out.pix.ycbcr_enc =3D pix_fmt->ycbcr_enc; + ctx->out.pix.quantization =3D pix_fmt->quantization; + ctx->out.pix.xfer_func =3D pix_fmt->xfer_func; + } + /* Reset crop settings */ frm->crop.left =3D 0; frm->crop.top =3D 0; --=20 2.53.0