From nobody Mon Jun 8 05:26:22 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 3417A1D9A5F for ; Fri, 5 Jun 2026 13:32:22 +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=1780666346; cv=none; b=e+HSiLfn3HMMwFgPSMueQv5l0r6GwusEetmP6bnRsqCRp4254GuDEswHdy/Bos5dvcxHhE1LORcZVEC2g8npli4ITRwbrlsUDel1UZKu5xvg41lSaWh4nlGr6iuJpXgM4TMVse1pEM7tjLhLgEXatsHFxBzJmb0M4npxWaGBLA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780666346; c=relaxed/simple; bh=jsU58i1TQ8GxtNs26qfV00swSBhq7f6YlSLTjWfxI1o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=KPdhY1BZiVJK554zNb84aso/wmzsUP66L3qAarWWB0KZ6fAG1wcWj8aT6tXAu4XazaASvoaleYfFSolR3VXXTy2QOVmu08NKaEoHG568F9ONlV/6V1FvQxJ5iO/sp2s7RqSgKY891fewFOGgW3SipfedJiwuFjrQvJrfaRoF6XA= 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 1wVUee-0000cf-1N; Fri, 05 Jun 2026 15:32:08 +0200 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Fri, 05 Jun 2026 15:32:01 +0200 Subject: [PATCH] media: rockchip: rga: don't change RGB quantization 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: <20260605-spu-fixrga3quantization-v1-1-1059d984dc6e@pengutronix.de> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMQQ6CMBAAv0L2bJMtxmr8ivGwlAXWQ8VuS4iEv 7vqcZKZ2UA5Cytcmw0yL6LyTAb+0ECcKI3spDeGFtuAAU9O5+oGWfNIx1elVORNxRqHwcdz8OT 7C4LVc2bTfufb/c9auwfH8t3Bvn8AsZjEBHsAAAA= X-Change-ID: 20260605-spu-fixrga3quantization-061c761a1d80 To: Jacob Chen , Ezequiel Garcia , Mauro Carvalho Chehab , Heiko Stuebner , Nicolas Dufresne , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Philipp Zabel , Michael Tretter , =?utf-8?q?Sven_P=C3=BCschel?= X-Mailer: b4 0.15.2 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 Don't change the quantization of an RGB format when converting between RGB and YUV with the RGA3. As the RGA3 only supports doing conversions to full range YUV with BT601, it wants to announce it through try_fmt/s_fmt. As it is only relevant, when converting between RGB and YUV, it's guarded by a given condition. But the condition also causes the RGB format quantization to be adjusted to limited range, which is incorrect. Therefore simplify the condition to only apply when the current format is a YUV format. Also document the reason for checking if the other format is an RGB format. Fixes: 24a63d4c9d3c ("media: rockchip: rga: add rga3 support") Signed-off-by: Sven P=C3=BCschel --- This patch is a fix to the upcoming RGA3 support. By mistake it'll also adjust the RGB quantization instead of only adjusting the quantization of the YUV formats. Therefore remove the incorrect conditions and document why we also check the format of the other side. I've just noticed this flawed condition and didn't check/reproduce it in a practical scenario. v4l2-compliance 1.32.0, 64 bits, 64-bit time_t .... Card type : rga3 ... Total for rockchip-rga device /dev/video0: 48, Succeeded: 48, Failed: 0= , Warnings: 0 v4l2-compliance 1.32.0, 64 bits, 64-bit time_t ... Card type : rga2 ... Total for rockchip-rga device /dev/video1: 48, Succeeded: 48, Failed: 0= , Warnings: 0 --- drivers/media/platform/rockchip/rga/rga3-hw.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rga/rga3-hw.c b/drivers/media/= platform/rockchip/rga/rga3-hw.c index ca1c268303dd4..c4a71306278ba 100644 --- a/drivers/media/platform/rockchip/rga/rga3-hw.c +++ b/drivers/media/platform/rockchip/rga/rga3-hw.c @@ -450,10 +450,14 @@ static void *rga3_adjust_and_map_format(struct rga_ct= x *ctx, other_format =3D is_output ? &ctx->out.pix : &ctx->in.pix; other_format_info =3D v4l2_format_info(other_format->pixelformat); =20 - if ((v4l2_is_format_rgb(format_info) && - v4l2_is_format_yuv(other_format_info)) || - (v4l2_is_format_yuv(format_info) && - v4l2_is_format_rgb(other_format_info))) { + /* + * Only apply the quantization restrictions when we need to + * convert between RGB and YUV. Otherwise there is no point + * to limit the quantization for operations like scaling or + * rotations. + */ + if (v4l2_is_format_yuv(format_info) && + v4l2_is_format_rgb(other_format_info)) { /* * The RGA3 only supports BT601, BT709 and BT2020 RGB<->YUV conversions * Additionally BT709 and BT2020 only support limited range YUV. --- base-commit: 6a75e3d4f6428b90f398354212e3a2e0172851d6 change-id: 20260605-spu-fixrga3quantization-061c761a1d80 Best regards, -- =20 Sven P=C3=BCschel