All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Marek Vasut <marex@denx.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH V4 1/2] drm/fb_cma_helper: Add drm_fb_cma_prepare_fb() helper
Date: Mon, 14 Nov 2016 11:32:27 +0100	[thread overview]
Message-ID: <1479119547.5657.0.camel@pengutronix.de> (raw)
In-Reply-To: <20161114100732.3446-1-marex@denx.de>

Am Montag, den 14.11.2016, 11:07 +0100 schrieb Marek Vasut:
> Add new drm_fb_cma_prepare_fb() helper function extracted from the
> imx-drm driver. This function checks if the plane has DMABUF attached
> to it, extracts the exclusive fence from it and attaches it to the
> plane state for the atomic helper to wait on it.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Lucas Stach <l.stach@pengutronix.de>

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>

> ---
> V2: Rename the function to drm_fb_cma_prepare_fb()
>     and clarify the documentation (thanks to Lucas Stach)
> V3: - Rename the function to drm_fb_cma_prepare_fb()
>     - Update documentation
> V4: Update to latest next/master (b60de3e)
> ---
>  drivers/gpu/drm/drm_fb_cma_helper.c | 35 +++++++++++++++++++++++++++++++++++
>  include/drm/drm_fb_cma_helper.h     |  3 +++
>  2 files changed, 38 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
> index 4c66644..7198373 100644
> --- a/drivers/gpu/drm/drm_fb_cma_helper.c
> +++ b/drivers/gpu/drm/drm_fb_cma_helper.c
> @@ -18,13 +18,16 @@
>   */
>  
>  #include <drm/drmP.h>
> +#include <drm/drm_atomic.h>
>  #include <drm/drm_crtc.h>
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_gem_cma_helper.h>
>  #include <drm/drm_fb_cma_helper.h>
> +#include <linux/dma-buf.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/module.h>
> +#include <linux/reservation.h>
>  
>  #define DEFAULT_FBDEFIO_DELAY_MS 50
>  
> @@ -265,6 +268,38 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb,
>  }
>  EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj);
>  
> +/**
> + * drm_fb_cma_prepare_fb() - Prepare CMA framebuffer
> + * @plane: Which plane
> + * @state: Plane state attach fence to
> + *
> + * This should be put into prepare_fb hook of struct &drm_plane_helper_funcs .
> + *
> + * This function checks if the plane FB has an dma-buf attached, extracts
> + * the exclusive fence and attaches it to plane state for the atomic helper
> + * to wait on.
> + *
> + * There is no need for cleanup_fb for CMA based framebuffer drivers.
> + */
> +int drm_fb_cma_prepare_fb(struct drm_plane *plane,
> +			  struct drm_plane_state *state)
> +{
> +	struct dma_buf *dma_buf;
> +	struct dma_fence *fence;
> +
> +	if ((plane->state->fb == state->fb) || !state->fb)
> +		return 0;
> +
> +	dma_buf = drm_fb_cma_get_gem_obj(state->fb, 0)->base.dma_buf;
> +	if (dma_buf) {
> +		fence = reservation_object_get_excl_rcu(dma_buf->resv);
> +		drm_atomic_set_fence_for_plane(state, fence);
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(drm_fb_cma_prepare_fb);
> +
>  #ifdef CONFIG_DEBUG_FS
>  static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m)
>  {
> diff --git a/include/drm/drm_fb_cma_helper.h b/include/drm/drm_fb_cma_helper.h
> index f313211..cc82c73 100644
> --- a/include/drm/drm_fb_cma_helper.h
> +++ b/include/drm/drm_fb_cma_helper.h
> @@ -41,6 +41,9 @@ struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev,
>  struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb,
>  	unsigned int plane);
>  
> +int drm_fb_cma_prepare_fb(struct drm_plane *plane,
> +			  struct drm_plane_state *state);
> +
>  #ifdef CONFIG_DEBUG_FS
>  struct seq_file;
>  


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2016-11-14 10:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 10:07 [PATCH V4 1/2] drm/fb_cma_helper: Add drm_fb_cma_prepare_fb() helper Marek Vasut
2016-11-14 10:07 ` [PATCH V4 2/2] drm/imx: Switch to " Marek Vasut
2016-11-14 10:32   ` Lucas Stach
2016-11-14 11:44     ` Daniel Vetter
2016-11-14 10:32 ` Lucas Stach [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=1479119547.5657.0.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=marex@denx.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 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.