From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Liu Ying <victor.liu@nxp.com>,
Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>,
Lucas Stach <l.stach@pengutronix.de>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej@kernel.org>,
Samuel Holland <samuel@sholland.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Chen-Yu Tsai <wenst@chromium.org>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
linux-sunxi@lists.linux.dev, imx@lists.linux.dev,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH RFT v3 3/5] drm/sun4i: layers: Fix VI buffer address for clipped offsets
Date: Wed, 25 Nov 2026 17:32:45 +0100 [thread overview]
Message-ID: <sBipOLw6T_aZ1e-H2zFl3g@gmail.com> (raw)
In-Reply-To: <20261124074041.115251-4-wenst@chromium.org>
Dne torek, 24. november 2026 ob 08:39:31 Srednjeevropski standardni čas je Chen-Yu Tsai napisal(a):
> Commit 79ac1c945ab8 ("drm/sun4i: layers: Use drm_fb_dma_get_gem_addr() to
> get display memory") dropped the code to calculate the framebuffer's DMA
> address in favor of drm_fb_dma_get_gem_addr().
>
> This turned out to be wrong in a couple ways. The hardware is programmed
> with clipped dimensions, so it needs the buffer address to start at the
> clipped boundary. Moving to the helper negated the clipping. Also, when
> clipping on the left, the buffer address needs to start at the first
> pixel in the sub-sampling group even for the luma plane. The hardware
> handles the interpolation internally.
>
> Switch to the new drm_fb_dma_get_gem_clipped_addr(), which provides the
> buffer address starting at the clipped boundary. Calculate the intra-group
> offset and adjust the luma plane buffer address so that it points to the
> start of the sub-sampling group.
>
> Fixes: 79ac1c945ab8 ("drm/sun4i: layers: Use drm_fb_dma_get_gem_addr() to get display memory")
> Cc: <stable@vger.kernel.org> # v7.1+, needs drm_fb_dma_get_gem_clipped_addr()
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> ---
> This is an alternative to Jernej's original revert:
> https://lore.kernel.org/all/3980ea1aeb3f7fe8b4700e36560deeba3d050664.1785772659.git.jernej.skrabec@gmail.com/
> ---
> drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 2 +-
> drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 16 +++++++++++++++-
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> index f9c7f28f9fa2..67cce1b0e70f 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> @@ -130,7 +130,7 @@ static void sun8i_ui_layer_update_buffer(struct sun8i_layer *layer,
> ch_base = sun8i_channel_base(layer);
>
> /* Get the start of the displayed memory */
> - dma_addr = drm_fb_dma_get_gem_addr(fb, state, 0);
> + dma_addr = drm_fb_dma_get_gem_clipped_addr(fb, state, 0);
>
> /* Set the line width */
> DRM_DEBUG_DRIVER("Layer line width: %d bytes\n", fb->pitches[0]);
> diff --git a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
> index 4d3fc03f9877..b6796416d550 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_vi_layer.c
> @@ -205,7 +205,21 @@ static void sun8i_vi_layer_update_buffer(struct sun8i_layer *layer,
>
> for (i = 0; i < format->num_planes; i++) {
> /* Get the start of the displayed memory */
> - dma_addr = drm_fb_dma_get_gem_addr(fb, state, i);
> + dma_addr = drm_fb_dma_get_gem_clipped_addr(fb, state, i);
> +
> + /*
> + * The mixer can handle odd offsets into sub-sampled YUV
> + * planes, but needs the address of the first pixel in each
> + * sub-sampled block. Adjust the luma buffer address backwards.
> + */
> + if (i == 0) {
> + u32 x_diff, y_diff;
> +
> + x_diff = (state->src.x1 >> 16) & (format->hsub - 1);
> + y_diff = (state->src.y1 >> 16) & (format->vsub - 1);
> + dma_addr -= y_diff * fb->pitches[i];
> + dma_addr -= x_diff * format->cpp[i];
> + }
This could be done differently.
Before for loop (done only once):
src_x = (state->src.x1 >> 16) & ~(format->hsub - 1);
src_y = (state->src.y1 >> 16) & ~(format->vsub - 1);
Inside for loop:
gem = drm_fb_dma_get_gem_obj(fb, i);
dma_addr = gem->dma_addr + drm_framebuffer_get_block_offset(fb, i, src_x, src_y);
But it works in any case, so:
Tested-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
>
> /* Set the line width */
> DRM_DEBUG_DRIVER("Layer %d. line width: %d bytes\n",
>
next prev parent reply other threads:[~2026-11-25 16:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 7:39 [PATCH RFT v3 0/5] drm: Add and use drm_fb_dma_get_gem_clipped_addr() helper Chen-Yu Tsai
2026-11-24 7:39 ` [PATCH RFT v3 1/5] drm: Split framebuffer pixel offset calculation from drm_fb_dma_get_gem_addr() Chen-Yu Tsai
2026-11-24 7:47 ` Thomas Zimmermann
2026-11-24 7:39 ` [PATCH RFT v3 2/5] drm/fb-dma-helper: Add drm_fb_dma_get_gem_clipped_addr() Chen-Yu Tsai
2026-11-24 7:57 ` Thomas Zimmermann
2026-11-24 10:22 ` Chen-Yu Tsai
2026-11-24 13:08 ` Thomas Zimmermann
2026-11-24 7:39 ` [PATCH RFT v3 3/5] drm/sun4i: layers: Fix VI buffer address for clipped offsets Chen-Yu Tsai
2026-11-25 16:32 ` Jernej Škrabec [this message]
2026-11-24 7:39 ` [PATCH RFT v3 4/5] drm/imx/dc: plane: Switch to drm_fb_dma_get_gem_clipped_addr() Chen-Yu Tsai
2026-11-24 7:39 ` [PATCH RFT v3 5/5] drm/imx/dcss: " Chen-Yu Tsai
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=sBipOLw6T_aZ1e-H2zFl3g@gmail.com \
--to=jernej.skrabec@gmail.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=imx@lists.linux.dev \
--cc=jernej@kernel.org \
--cc=l.stach@pengutronix.de \
--cc=laurentiu.palcu@oss.nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=samuel@sholland.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=tzimmermann@suse.de \
--cc=victor.liu@nxp.com \
--cc=wens@kernel.org \
--cc=wenst@chromium.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.