From nobody Tue Feb 10 05:44:57 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 7F7A335FF67 for ; Tue, 27 Jan 2026 14:40:19 +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=1769524821; cv=none; b=fCbfGSpnOyCAz3Xu5yGvvyJ8xrpvIfYsh3zzgLmPy7L/FEZJHDXYJP2pFY6gx9FK9cuQ0ia/nWv2kpiG70FDonO1IttBtN8w/xfn3ueW7ec4CA5iruuSaoLid9GkKTA28UofvVIXCC445C9fi/cQwpiajiwWSphza2IVLt++09w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769524821; c=relaxed/simple; bh=sQRBR8hqsVnFilBb4IeM1DRR5keXwvKE0i990WgKU4w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sh5oLhY/QGOisGzE+CGkkTLnWWlopy4gjOH18z4C2pYec7iebMMkzFDGUKH192Yvh8BRA9EfofPpPan6xO/KmtbyubztvnwJmtu0ASMZTPX+tXvFPfpjal693nvbhyv6oC4FS/C+KmSfisPLmvL0c8LOLxb2ikyPIsOo92feXHQ= 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 1vkkEr-0007YT-E5; Tue, 27 Jan 2026 15:40:17 +0100 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Tue, 27 Jan 2026 15:39:20 +0100 Subject: [PATCH v3 11/27] media: rockchip: rga: avoid odd frame sizes for YUV formats 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: <20260127-spu-rga3-v3-11-77b273067beb@pengutronix.de> References: <20260127-spu-rga3-v3-0-77b273067beb@pengutronix.de> In-Reply-To: <20260127-spu-rga3-v3-0-77b273067beb@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, =?utf-8?q?Sven_P=C3=BCschel?= X-Mailer: b4 0.14.3 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 Avoid odd frame sizes for YUV formats, as they may cause undefined behavior. This is done in preparation for the RGA3, which hangs when the output format is set to 129x129 pixel YUV420 SP (NV12). This requirement is documented explicitly for the RGA3 in section 5.6.3 of the RK3588 TRM Part 2. For the RGA2 the RK3588 TRM Part 2 (section 6.1.2) and RK3568 TRM Part 2 (section 14.2) only mentions the x/y offsets and stride aligning requirements. But the vendor driver for the RGA2 also contains checks for the width and height to be aligned to 2 bytes. Signed-off-by: Sven P=C3=BCschel --- drivers/media/platform/rockchip/rga/rga.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/plat= form/rockchip/rga/rga.c index 21a3c6cd38dbc..4fa6adb10b7ee 100644 --- a/drivers/media/platform/rockchip/rga/rga.c +++ b/drivers/media/platform/rockchip/rga/rga.c @@ -337,6 +337,19 @@ static int vidioc_try_fmt(struct file *file, void *pri= v, struct v4l2_format *f) struct rga_ctx *ctx =3D file_to_rga_ctx(file); const struct rga_hw *hw =3D ctx->rga->hw; struct rga_fmt *fmt; + struct v4l2_frmsize_stepwise frmsize =3D { + .min_width =3D hw->min_width, + .max_width =3D hw->max_width, + .min_height =3D hw->min_height, + .max_height =3D hw->max_height, + .step_width =3D 1, + .step_height =3D 1, + }; + + if (v4l2_is_format_yuv(v4l2_format_info(pix_fmt->pixelformat))) { + frmsize.step_width =3D 2; + frmsize.step_height =3D 2; + } =20 if (V4L2_TYPE_IS_CAPTURE(f->type)) { const struct rga_frame *frm; @@ -358,11 +371,7 @@ static int vidioc_try_fmt(struct file *file, void *pri= v, struct v4l2_format *f) if (!fmt) fmt =3D &hw->formats[0]; =20 - pix_fmt->width =3D clamp(pix_fmt->width, - hw->min_width, hw->max_width); - pix_fmt->height =3D clamp(pix_fmt->height, - hw->min_height, hw->max_height); - + v4l2_apply_frmsize_constraints(&pix_fmt->width, &pix_fmt->height, &frmsiz= e); v4l2_fill_pixfmt_mp(pix_fmt, fmt->fourcc, pix_fmt->width, pix_fmt->height= ); pix_fmt->field =3D V4L2_FIELD_NONE; =20 --=20 2.52.0