From mboxrd@z Thu Jan 1 00:00:00 1970 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 571293EF66E for ; Wed, 25 Mar 2026 14:51:02 +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=1774450270; cv=none; b=t0tzMWoO/a/HXNRI/vafcxvw6yODhj1pUdHcHMn8XwG50SVUN1qFtafpsU8RMuXIZ3Lk8+9k7ox0vsUIgfWnTpuzXW9C2bR7SPvPX+7d/69aod+i+X7xymv93AWRZ2I1zrE3hWVEeX0WHYHy1ZFXuCtN6VZY+ZvU65i2D8+DWuY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774450270; c=relaxed/simple; bh=MlWFscgcOlnXGuul8LgcZWAOtehT2VukGin7QDSyz2Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Bqka6LhqMmw2QdLjslpE9+Pfjx1kN8bsXU9sfCE1bAbRzAkOGBmedI5uNq/pKO9UruotbxnC/R1R0V12NDvAiF6wKS2SsG6ERLGHV1Sof6pB9Jt3iJH/RmUPTcxMGg9blVoIcUtrmgu+UhrOEDuukV8wJb8ItbMI8MEHXY6S1sg= 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 1w5PZU-00050C-6P; Wed, 25 Mar 2026 15:51:00 +0100 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Wed, 25 Mar 2026 15:50:42 +0100 Subject: [PATCH v4 11/27] media: rockchip: rga: avoid odd frame sizes for YUV formats Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260325-spu-rga3-v4-11-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?= 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-media@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üschel --- 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/platform/rockchip/rga/rga.c index f599c992829dd..77b8c7ab74274 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 *priv, struct v4l2_format *f) struct rga_ctx *ctx = file_to_rga_ctx(file); const struct rga_hw *hw = ctx->rga->hw; struct rga_fmt *fmt; + struct v4l2_frmsize_stepwise frmsize = { + .min_width = hw->min_width, + .max_width = hw->max_width, + .min_height = hw->min_height, + .max_height = hw->max_height, + .step_width = 1, + .step_height = 1, + }; + + if (v4l2_is_format_yuv(v4l2_format_info(pix_fmt->pixelformat))) { + frmsize.step_width = 2; + frmsize.step_height = 2; + } 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 *priv, struct v4l2_format *f) if (!fmt) fmt = &hw->formats[0]; - pix_fmt->width = clamp(pix_fmt->width, - hw->min_width, hw->max_width); - pix_fmt->height = clamp(pix_fmt->height, - hw->min_height, hw->max_height); - + v4l2_apply_frmsize_constraints(&pix_fmt->width, &pix_fmt->height, &frmsize); v4l2_fill_pixfmt_mp(pix_fmt, fmt->fourcc, pix_fmt->width, pix_fmt->height); pix_fmt->field = V4L2_FIELD_NONE; -- 2.53.0