From nobody Tue Feb 10 05:44:55 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 74B5B35F8C5 for ; Tue, 27 Jan 2026 14:40:26 +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=1769524828; cv=none; b=OkWOKkyPfuQaUyqoXvvahkqHE1gM4qXpNLGgyd2SrAB+9ENv7vNKXg07tmrWq3amQBOJ4j6IBObeVmdBIAEqTuTUAj3BQrvpB5medNWvFS4krDrvPR/WUN+JK1VBjUYVi/KfgrzPTSmeo/5vkxgmItJYf7cGkDCBhHePr1npkqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769524828; c=relaxed/simple; bh=/k7y+ulhazQXhid7mmqv3l/6j4W1vDnO4DejkulkWtk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FsD4TRBa3Zo11uEJLZzGOKkbCyR+qRNGkb6ymKjBJwCZYrD0YzV/DtFDQOstk6SdifR+awvpW9nBBwRYU6GFxWIfsfBx+E7vEHHzSD8H9tDNv7zQYJbVpAHgMyKeoFodGDGr3DZPY7Ckza3gY5qRcDUUw9HGYPmO7LzWra5PaZM= 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 1vkkEx-0007YT-ME; Tue, 27 Jan 2026 15:40:23 +0100 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Tue, 27 Jan 2026 15:39:23 +0100 Subject: [PATCH v3 14/27] 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: <20260127-spu-rga3-v3-14-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 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 caf2424962351..16380be598e4a 100644 --- a/drivers/media/platform/rockchip/rga/rga-hw.c +++ b/drivers/media/platform/rockchip/rga/rga-hw.c @@ -580,6 +580,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 ac42e905a88cd..2920efe65082a 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; @@ -393,7 +393,8 @@ static int vidioc_try_fmt(struct file *file, void *priv= , struct v4l2_format *f) fmt =3D &hw->formats[0]; =20 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= ); + 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 04aeb7b429523..38518146910a6 100644 --- a/drivers/media/platform/rockchip/rga/rga.h +++ b/drivers/media/platform/rockchip/rga/rga.h @@ -150,6 +150,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