From: Marek Vasut <marex@denx.de>
To: dri-devel@lists.freedesktop.org
Cc: Marek Vasut <marex@denx.de>, Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 1/2] drm/fb_cma_helper: Add drm_fb_cma_setup_fence() helper
Date: Mon, 26 Sep 2016 15:01:03 +0200 [thread overview]
Message-ID: <20160926130104.8977-1-marex@denx.de> (raw)
Add new drm_fb_cma_setup_fence() helper function extracted from the
imx-drm driver. This function checks if the plane has DMABUF attached
to it and if so, sets up the fence on which the atomic helper can wait.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Lucas Stach <l.stach@pengutronix.de>
---
drivers/gpu/drm/drm_fb_cma_helper.c | 26 ++++++++++++++++++++++++++
include/drm/drm_fb_cma_helper.h | 3 +++
2 files changed, 29 insertions(+)
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 1fd6eac..2441707 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -23,8 +23,10 @@
#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 +267,30 @@ 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_setup_fence() - Set up the fence for atomic helper to wait on
+ * @plane: Which plane
+ * @state: Plane state to check
+ *
+ * If the plane fb has an dma-buf attached, fish out the exclusive
+ * fence for the atomic helper to wait on.
+ */
+void drm_fb_cma_setup_fence(struct drm_plane *plane,
+ struct drm_plane_state *state)
+{
+ struct dma_buf *dma_buf;
+
+ if ((plane->state->fb == state->fb) || !state->fb)
+ return;
+
+ dma_buf = drm_fb_cma_get_gem_obj(state->fb, 0)->base.dma_buf;
+ if (!dma_buf)
+ return;
+
+ state->fence = reservation_object_get_excl_rcu(dma_buf->resv);
+}
+EXPORT_SYMBOL_GPL(drm_fb_cma_setup_fence);
+
#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..fc122d3 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);
+void drm_fb_cma_setup_fence(struct drm_plane *plane,
+ struct drm_plane_state *state);
+
#ifdef CONFIG_DEBUG_FS
struct seq_file;
--
2.9.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2016-09-26 13:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-26 13:01 Marek Vasut [this message]
2016-09-26 13:01 ` [PATCH 2/2] drm/imx: Switch to drm_fb_cma_setup_fence() helper Marek Vasut
2016-09-28 13:57 ` Lucas Stach
2016-09-28 20:09 ` Marek Vasut
2016-09-29 9:37 ` Daniel Vetter
2016-09-29 21:40 ` Marek Vasut
2016-09-28 13:55 ` [PATCH 1/2] drm/fb_cma_helper: Add " Lucas Stach
2016-09-28 20:08 ` Marek Vasut
2016-09-29 9:36 ` Daniel Vetter
2016-09-29 21:44 ` Marek Vasut
2016-09-30 9:53 ` Daniel Vetter
2016-10-02 17:19 ` Marek Vasut
2016-10-03 13:54 ` Daniel Vetter
2016-10-05 14:50 ` Marek Vasut
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=20160926130104.8977-1-marex@denx.de \
--to=marex@denx.de \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.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;
as well as URLs for NNTP newsgroup(s).