From nobody Mon Feb 9 23:41:46 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 19472338934 for ; Wed, 3 Dec 2025 15:54:06 +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=1764777248; cv=none; b=qWQ+WVT4MTXa9qn6hq/Rd84s+9zh1nMPXmdt93WHliLhy5Kvq2RO1op+tAwGxbyCXbdUD3X+yHME/PeW4oiNjXtvTZyawMFHVybBZD/2l51G32b1lgt3HmWKwkq0FBK/U/Z2xnk5B2BE9xohdBO2e+7coQK2q0H7svnONj4xJuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764777248; c=relaxed/simple; bh=B0/KFgd5fKwQ5qWLSoIA/yamG6f4fKjqnvtRf6hq2P8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iHXW99aYs50Pv0gzqq+nSbIFrFz5jy/WcMA1Uy2xPwUb9YZVu03eulFqRFMAcxRkFQsG3dv80XD+q+y0I8AUwyORYC5wz3xb1mahufXEsc+6oleXsOPMr+GejkWF/wD2Xp3nmvS6pQ6aiA/u+SHms2f2kruWvTJ8AsTzF06ghdg= 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 1vQpAd-0007dW-Db; Wed, 03 Dec 2025 16:53:35 +0100 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Wed, 03 Dec 2025 16:52:31 +0100 Subject: [PATCH v2 09/22] media: rockchip: rga: align stride to 4 bytes 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: <20251203-spu-rga3-v2-9-989a67947f71@pengutronix.de> References: <20251203-spu-rga3-v2-0-989a67947f71@pengutronix.de> In-Reply-To: <20251203-spu-rga3-v2-0-989a67947f71@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 Add an alignment setting to rga_hw to set the desired stride alignment. As the RGA2 register for the stride counts in word units, the code already divides the bytesperline value by 4 when writing it into the register. Therefore fix the alignment to a multiple of 4 to avoid potential off by one errors due from the division. Signed-off-by: Sven P=C3=BCschel --- drivers/media/platform/rockchip/rga/rga-hw.c | 1 + drivers/media/platform/rockchip/rga/rga.c | 11 ++++++----- drivers/media/platform/rockchip/rga/rga.h | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rockchip/rga/rga-hw.c b/drivers/media/p= latform/rockchip/rga/rga-hw.c index 79bf911e74779..56a2558539bfb 100644 --- a/drivers/media/platform/rockchip/rga/rga-hw.c +++ b/drivers/media/platform/rockchip/rga/rga-hw.c @@ -620,6 +620,7 @@ const struct rga_hw rga2_hw =3D { .max_width =3D MAX_WIDTH, .min_height =3D MIN_HEIGHT, .max_height =3D MAX_HEIGHT, + .stride_alignment =3D 4, =20 .start =3D rga_hw_start, .handle_irq =3D rga_handle_irq, diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/plat= form/rockchip/rga/rga.c index 74d94c7fe31ff..592c977a07cf3 100644 --- a/drivers/media/platform/rockchip/rga/rga.c +++ b/drivers/media/platform/rockchip/rga/rga.c @@ -234,10 +234,10 @@ static int rga_open(struct file *file) ctx->in =3D def_frame; ctx->out =3D def_frame; =20 - v4l2_fill_pixfmt_mp(&ctx->in.pix, - ctx->in.fmt->fourcc, def_width, def_height); - v4l2_fill_pixfmt_mp(&ctx->out.pix, - ctx->out.fmt->fourcc, def_width, def_height); + v4l2_fill_pixfmt_mp_aligned(&ctx->in.pix, ctx->in.fmt->fourcc, + def_width, def_height, rga->hw->stride_alignment); + v4l2_fill_pixfmt_mp_aligned(&ctx->out.pix, ctx->out.fmt->fourcc, + def_width, def_height, rga->hw->stride_alignment); =20 if (mutex_lock_interruptible(&rga->mutex)) { ret =3D -ERESTARTSYS; @@ -359,7 +359,8 @@ static int vidioc_try_fmt(struct file *file, void *priv= , struct v4l2_format *f) pix_fmt->height =3D clamp(pix_fmt->height, hw->min_height, hw->max_height); =20 - v4l2_fill_pixfmt_mp(pix_fmt, fmt->fourcc, pix_fmt->width, pix_fmt->height= ); + v4l2_fill_pixfmt_mp_aligned(pix_fmt, pix_fmt->pixelformat, + pix_fmt->width, pix_fmt->height, hw->stride_alignment); pix_fmt->field =3D V4L2_FIELD_NONE; =20 return 0; diff --git a/drivers/media/platform/rockchip/rga/rga.h b/drivers/media/plat= form/rockchip/rga/rga.h index f8c932fdec21a..0aef348dddb95 100644 --- a/drivers/media/platform/rockchip/rga/rga.h +++ b/drivers/media/platform/rockchip/rga/rga.h @@ -152,6 +152,7 @@ struct rga_hw { size_t cmdbuf_size; u32 min_width, min_height; u32 max_width, max_height; + u8 stride_alignment; =20 void (*start)(struct rockchip_rga *rga, struct rga_vb_buffer *src, struct rga_vb_buffer *dst); --=20 2.52.0