mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Chen-Yu Tsai <wenst@chromium.org>
Cc: 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>,
	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 2/5] drm/fb-dma-helper: Add drm_fb_dma_get_gem_clipped_addr()
Date: Tue, 24 Nov 2026 14:08:58 +0100	[thread overview]
Message-ID: <93890802-060e-4369-842e-2a02bbd2042c@suse.de> (raw)
In-Reply-To: <CAGXv+5HSV7MJ96qTcOp+JaKWtmmYYWAmDROrT18pZ9PztNCJ-g@mail.gmail.com>

Hi

Am 24.11.26 um 11:22 schrieb Chen-Yu Tsai:
> On Tue, Nov 24, 2026 at 3:57 PM Thomas Zimmermann <tzimmermann@suse.de> wrote:
>> Hi
>>
>> Am 24.11.26 um 08:39 schrieb Chen-Yu Tsai:
>>> drm_fb_dma_get_gem_addr() returns the DMA address to the "unclipped"
>>> framebuffer. However some display drivers want the "clipped" framebuffer
>>> instead, as they are also using the clipped coordinates to program the
>>> hardware.
>>>
>>> Some of these drivers are open-coding drm_fb_dma_get_gem_addr() with
>>> the source coordinates replaced, while others have been incorrectly
>>> converted to using drm_fb_dma_get_gem_addr(), which would end up
>>> causing incorrect parts of the framebuffer to be displayed if it were
>>> somehow clipped.
>>>
>>> Add drm_fb_dma_get_gem_clipped_addr(), a "clipped" version of
>>> drm_fb_dma_get_gem_addr() for these drivers to use.
>>>
>>> Cc: <stable@vger.kernel.org> # dependency for next patch
>>> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
>>> ---
>>> Changes since v1:
>>> - Use new drm_framebuffer_get_block_offset() helper
>>> ---
>>>    drivers/gpu/drm/drm_fb_dma_helper.c | 37 +++++++++++++++++++++++++----
>>>    include/drm/drm_fb_dma_helper.h     |  4 ++++
>>>    2 files changed, 37 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_fb_dma_helper.c b/drivers/gpu/drm/drm_fb_dma_helper.c
>>> index ab0f37d8a5ff..0aaf4926db4e 100644
>>> --- a/drivers/gpu/drm/drm_fb_dma_helper.c
>>> +++ b/drivers/gpu/drm/drm_fb_dma_helper.c
>>> @@ -60,15 +60,16 @@ struct drm_gem_dma_object *drm_fb_dma_get_gem_obj(struct drm_framebuffer *fb,
>>>    EXPORT_SYMBOL_GPL(drm_fb_dma_get_gem_obj);
>>>
>>>    /**
>>> - * drm_fb_dma_get_gem_addr() - Get DMA (bus) address for framebuffer, for pixel
>>> - * formats where values are grouped in blocks this will get you the beginning of
>>> - * the block
>>> + * drm_fb_dma_get_gem_addr() - Get DMA (bus) address for unclipped framebuffer,
>>> + * for pixel formats where values are grouped in blocks this will get you the
>>> + * beginning of the block
>>>     * @fb: The framebuffer
>>>     * @state: Which state of drm plane
>>>     * @plane: Which plane
>>> - * Return the DMA GEM address for given framebuffer.
>>>     *
>>>     * This function will usually be called from the PLANE callback functions.
>>> + *
>>> + * Return: GEM DMA address for given framebuffer, unclipped.
>>>     */
>>>    dma_addr_t drm_fb_dma_get_gem_addr(struct drm_framebuffer *fb,
>>>                                   struct drm_plane_state *state,
>>> @@ -86,6 +87,34 @@ dma_addr_t drm_fb_dma_get_gem_addr(struct drm_framebuffer *fb,
>>>    }
>>>    EXPORT_SYMBOL_GPL(drm_fb_dma_get_gem_addr);
>>>
>>> +/**
>>> + * drm_fb_dma_get_gem_clipped_addr() - Get DMA (bus) address for clipped
>>> + * framebuffer, for pixel formats where values are grouped in blocks this
>>> + * will get you the beginning of the block
>>> + * @fb: The framebuffer
>>> + * @state: Which state of drm plane
>>> + * @plane: Which plane
>>> + *
>>> + * This function will usually be called from the PLANE callback functions.
>> You should mention what clipping means in this context. It's not obvious
>> what it's clipping against. Or maybe point to other docs that explain it.
> What about:
>
> /**
>   * drm_fb_dma_get_gem_clipped_addr() - Get DMA (bus) address for the start
>   * of the visible (CRTC-clipped) part of the framebuffer
>   * @fb: The framebuffer
>   * @state: Which state of drm plane
>   * @plane: Which plane
>   *
>   * A plane may be positioned partially off-screen, in which case it gets
>   * clipped to the visible CRTC area by drm_atomic_helper_check_plane_state()
>   * (populating the clipped coordinates in &drm_plane_state.src and
>   * &drm_plane_state.dst). For example, if a plane extends past the left or
>   * top edge of the screen, only its right and/or bottom portion is visible.
>   * Drivers whose hardware cannot clip by itself (i.e. accept negative
>   * destination coordinates) should use this helper instead of
>   * drm_fb_dma_get_gem_addr() so scanout starts from the visible portion of
>   * the framebuffer.
>   *
>   * For pixel formats where values are grouped in blocks, this returns the
>   * beginning of the block.
>   *
>   * This function will usually be called from the PLANE callback functions.
>   *
>   * Return: GEM DMA address for the visible part of the framebuffer.
>   */

Looks good.

>
>>> + *
>>> + * Return: GEM DMA address for given framebuffer, clipped.
>>> + */
>>> +dma_addr_t drm_fb_dma_get_gem_clipped_addr(struct drm_framebuffer *fb,
>>> +                                        struct drm_plane_state *state,
>>> +                                        unsigned int plane)
>>> +{
>>> +     struct drm_gem_dma_object *obj;
>>> +
>>> +     obj = drm_fb_dma_get_gem_obj(fb, plane);
>>> +     if (!obj)
>>> +             return 0;
>>> +
>>> +     return obj->dma_addr + drm_framebuffer_get_block_offset(fb, plane,
>>> +                                                             state->src.x1 >> 16,
>>> +                                                             state->src.y1 >> 16);
>> I had to look several times to spot the difference to the regular
> I suppose I should add a comment to make the difference more visible:
>
>      /* Use clipped source coordinates state->src.[xy]1 instead ->src_[xy] */

Your choice.

>
>> helper. In any case
>>
>> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> If the changes above are acceptable to you I'll send out a new version
> with your tag kept.

Sure, go ahead.

Best regards
Thomas

>
>
> Thanks
> ChenYu

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



  reply	other threads:[~2026-11-24 13:09 UTC|newest]

Thread overview: 10+ 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 [this message]
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-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=93890802-060e-4369-842e-2a02bbd2042c@suse.de \
    --to=tzimmermann@suse.de \
    --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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®