From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej@kernel.org>,
Samuel Holland <samuel@sholland.org>,
wens@kernel.org
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
linux-sunxi@lists.linux.dev, dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/sun4i: layers: Use drm_fb_dma_get_gem_addr() to get display memory
Date: Wed, 18 Mar 2026 20:28:23 +0100 [thread overview]
Message-ID: <6247601.lOV4Wx5bFT@jernej-laptop> (raw)
In-Reply-To: <CAGb2v67sA48gfecLKiGozULmTo45hXF25n+2+nAHVFY_QEL24w@mail.gmail.com>
Dne sreda, 18. marec 2026 ob 10:35:35 Srednjeevropski standardni čas je Chen-Yu Tsai napisal(a):
> Hi,
>
> On Tue, Mar 10, 2026 at 12:56 AM Chen-Yu Tsai <wens@kernel.org> wrote:
> >
> > Commit 4636ce93d5b2 ("drm/fb-cma-helper: Add drm_fb_cma_get_gem_addr()")
> > adds a new helper, which covers fetching a drm_framebuffer's GEM object
> > and calculating the buffer address for a given plane.
> >
> > This patch uses this helper to replace our own open coded version of the
> > same function.
> >
> > Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
> > ---
> > drivers/gpu/drm/sun4i/sun8i_ui_layer.c | 16 ++-------------
> > drivers/gpu/drm/sun4i/sun8i_vi_layer.c | 27 ++------------------------
> > 2 files changed, 4 insertions(+), 39 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> > index f08f6da55dd0..72c92203ae63 100644
> > --- a/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> > +++ b/drivers/gpu/drm/sun4i/sun8i_ui_layer.c
> > @@ -124,25 +124,13 @@ static void sun8i_ui_layer_update_buffer(struct sun8i_layer *layer,
> > {
> > struct drm_plane_state *state = plane->state;
> > struct drm_framebuffer *fb = state->fb;
> > - struct drm_gem_dma_object *gem;
> > dma_addr_t dma_addr;
> > u32 ch_base;
> > - int bpp;
> >
> > ch_base = sun8i_channel_base(layer);
> >
> > - /* Get the physical address of the buffer in memory */
> > - gem = drm_fb_dma_get_gem_obj(fb, 0);
> > -
> > - DRM_DEBUG_DRIVER("Using GEM @ %pad\n", &gem->dma_addr);
> > -
> > - /* Compute the start of the displayed memory */
> > - bpp = fb->format->cpp[0];
> > - dma_addr = gem->dma_addr + fb->offsets[0];
> > -
> > - /* Fixup framebuffer address for src coordinates */
> > - dma_addr += (state->src.x1 >> 16) * bpp;
> > - dma_addr += (state->src.y1 >> 16) * fb->pitches[0];
> > + /* Get the start of the displayed memory */
> > + dma_addr = drm_fb_dma_get_gem_addr(fb, state, 0);
>
> I just realized while reading more code that there's a subtle difference
> here.
>
> The original code used state->src.x1, which is the "clipped" coordinates,
> while drm_fb_dma_get_gem_addr() uses state->src_x, which is the original
> coordinates.
>
> Jernej, do you know which one the driver is supposed to use? Or maybe
> it doesn't matter?
I would say that it doesn't matter for point of origin. Original coordinates
use uint32_t values which means origin cannot be out of screen (negative
numbers). What I found interesting is that clipped coordinates are int, e.g.
they can be negative.
Best regards,
Jernej
prev parent reply other threads:[~2026-03-18 19:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 16:56 [PATCH] drm/sun4i: layers: Use drm_fb_dma_get_gem_addr() to get display memory Chen-Yu Tsai
2026-03-09 17:57 ` Jernej Škrabec
2026-03-14 13:13 ` Chen-Yu Tsai
2026-03-18 9:35 ` Chen-Yu Tsai
2026-03-18 19:28 ` Jernej Škrabec [this message]
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=6247601.lOV4Wx5bFT@jernej-laptop \
--to=jernej.skrabec@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej@kernel.org \
--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=tzimmermann@suse.de \
--cc=wens@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox