[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251007-spu-rga3-v1-3-36ad85570402@pengutronix.de>
Date: Tue, 07 Oct 2025 10:31:56 +0200
From: Sven Püschel <s.pueschel@...gutronix.de>
To: Jacob Chen <jacob-chen@...wrt.com>,
Ezequiel Garcia <ezequiel@...guardiasur.com.ar>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Heiko Stuebner <heiko@...ech.de>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>
Cc: linux-media@...r.kernel.org, linux-rockchip@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, kernel@...gutronix.de,
Sven Püschel <s.pueschel@...gutronix.de>
Subject: [PATCH 03/16] media: rockchip: rga: align stride to 16 bytes
Align the stride to a multiple of 16 according to the RGA3 requirements
mentioned in the datasheet. This also ensures that the stride of the RGA2
is aligned to 4 bytes, as it needs to divide the value by 4 (one word)
before storing it in the register.
Increasing the stride for the alignment also requires to increase the
sizeimage value. This is usually handled by v4l2_fill_pixfmt_mp, but
it doesn't allow to set a stride alignment. Therefore use the generated
values to calculate the total number of lines to properly update the
sizeimage value after the bytesperline has been aligned.
Signed-off-by: Sven Püschel <s.pueschel@...gutronix.de>
---
drivers/media/platform/rockchip/rga/rga.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index 6438119a6c7aeff1e89e7aa95dcd5d2921fefa08..3cb7ce470c47e39d694e8176875a75fad2717f96 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -459,6 +459,25 @@ static int vidioc_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *f
return 0;
}
+static void align_pixfmt(struct v4l2_pix_format_mplane *pix_fmt)
+{
+ int lines;
+ struct v4l2_plane_pix_format *fmt;
+
+ /*
+ * Align stride to 16 for the RGA3 (based on the datasheet)
+ * To not dismiss the v4l2_fill_pixfmt_mp helper
+ * (and manually write it again), we're approximating the new sizeimage
+ */
+ for (fmt = pix_fmt->plane_fmt;
+ fmt < pix_fmt->plane_fmt + pix_fmt->num_planes;
+ fmt++) {
+ lines = DIV_ROUND_UP(fmt->sizeimage, fmt->bytesperline);
+ fmt->bytesperline = (fmt->bytesperline + 0xf) & ~0xf;
+ fmt->sizeimage = fmt->bytesperline * lines;
+ }
+}
+
static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
struct v4l2_pix_format_mplane *pix_fmt = &f->fmt.pix_mp;
@@ -474,6 +493,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
return PTR_ERR(frm);
v4l2_fill_pixfmt_mp(pix_fmt, frm->fmt->fourcc, frm->width, frm->height);
+ align_pixfmt(pix_fmt);
pix_fmt->field = V4L2_FIELD_NONE;
pix_fmt->colorspace = frm->colorspace;
@@ -496,6 +516,7 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
(u32)MIN_HEIGHT, (u32)MAX_HEIGHT);
v4l2_fill_pixfmt_mp(pix_fmt, fmt->fourcc, pix_fmt->width, pix_fmt->height);
+ align_pixfmt(pix_fmt);
pix_fmt->field = V4L2_FIELD_NONE;
return 0;
--
2.51.0
Powered by blists - more mailing lists