From: Nicolas Dufresne <nicolas@ndufresne.ca>
To: "Sven Püschel" <s.pueschel@pengutronix.de>,
"Jacob Chen" <jacob-chen@iotwrt.com>,
"Ezequiel Garcia" <ezequiel@vanguardiasur.com.ar>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>
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
Subject: Re: [PATCH 03/16] media: rockchip: rga: align stride to 16 bytes
Date: Tue, 07 Oct 2025 14:19:15 -0400 [thread overview]
Message-ID: <db7030790063d0ebe6d254c7053e758184b9d7cc.camel@ndufresne.ca> (raw)
In-Reply-To: <20251007-spu-rga3-v1-3-36ad85570402@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 2964 bytes --]
Hi,
Le mardi 07 octobre 2025 à 10:31 +0200, Sven Püschel a écrit :
> 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@pengutronix.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..3cb7ce470c47e39d694e8176875a75fad271
> 7f96 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;
Instead of open coding this, describe this with struct v4l2_frmsize_stepwise and
then use v4l2_apply_frmsize_constraints().
Nicolas
> + }
> +}
> +
> 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;
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2025-10-07 18:19 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 8:31 [PATCH 00/16] media: platform: rga: Add RGA3 support Sven Püschel
2025-10-07 8:31 ` [PATCH 01/16] media: rockchip: rga: use clk_bulk api Sven Püschel
2025-10-07 8:31 ` [PATCH 02/16] media: rockchip: rga: use stride for offset calculation Sven Püschel
2025-10-07 8:31 ` [PATCH 03/16] media: rockchip: rga: align stride to 16 bytes Sven Püschel
2025-10-07 18:19 ` Nicolas Dufresne [this message]
2025-10-07 8:31 ` [PATCH 04/16] media: rockchip: rga: move hw specific parts to a dedicated struct Sven Püschel
2025-10-07 8:31 ` [PATCH 05/16] media: rockchip: rga: use card type to specify rga type Sven Püschel
2025-10-07 8:31 ` [PATCH 06/16] media: rockchip: rga: change offset to dma_addresses Sven Püschel
2025-10-07 8:32 ` [PATCH 07/16] media: rockchip: rga: support external iommus Sven Püschel
2025-10-07 8:32 ` [PATCH 08/16] media: rockchip: rga: remove size from rga_frame Sven Püschel
2025-10-07 8:32 ` [PATCH 09/16] media: rockchip: rga: remove stride " Sven Püschel
2025-10-07 8:32 ` [PATCH 10/16] media: rockchip: rga: move rga_fmt to rga-hw.h Sven Püschel
2025-10-07 8:32 ` [PATCH 11/16] media: rockchip: rga: add iommu restore function Sven Püschel
2025-10-07 18:30 ` Nicolas Dufresne
2025-10-10 8:45 ` Sven Püschel
2025-10-10 13:10 ` Nicolas Dufresne
2025-10-07 8:32 ` [PATCH 12/16] media: rockchip: rga: handle error interrupt Sven Püschel
2025-10-07 18:47 ` Nicolas Dufresne
2025-10-07 8:32 ` [PATCH 13/16] media: dt-bindings: media: rockchip-rga: add rockchip,rk3588-rga3 Sven Püschel
2025-10-07 8:38 ` Krzysztof Kozlowski
2025-10-07 18:12 ` Nicolas Dufresne
2025-10-07 8:32 ` [PATCH 14/16] arm64: dts: rockchip: add rga3 dt nodes Sven Püschel
2025-10-07 8:32 ` [PATCH 15/16] arm64: dts: rockchip: increase rga3 clock speed Sven Püschel
2025-10-07 8:39 ` Krzysztof Kozlowski
2025-10-07 8:32 ` [PATCH 16/16] media: rockchip: rga: add rga3 support Sven Püschel
2025-10-07 8:39 ` Krzysztof Kozlowski
2025-10-07 16:05 ` Sven Püschel
2025-10-08 1:55 ` Krzysztof Kozlowski
2025-10-07 18:54 ` Nicolas Dufresne
2025-10-07 19:41 ` Nicolas Dufresne
2025-10-10 9:21 ` Sven Püschel
2025-10-11 5:32 ` kernel test robot
2025-10-07 18:06 ` [PATCH 00/16] media: platform: rga: Add RGA3 support Nicolas Dufresne
2025-10-10 8:33 ` Sven Püschel
2025-10-10 13:05 ` Nicolas Dufresne
2025-10-09 22:03 ` Rob Herring (Arm)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db7030790063d0ebe6d254c7053e758184b9d7cc.camel@ndufresne.ca \
--to=nicolas@ndufresne.ca \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=heiko@sntech.de \
--cc=jacob-chen@iotwrt.com \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=s.pueschel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).