[Mesa-dev] [RFC 1/7] xa: add xa_surface_from_handle()

Rob Clark robdclark at gmail.com
Tue May 28 07:13:26 PDT 2013


From: Rob Clark <robclark at freedesktop.org>

For freedreno DDX, we have to create the scanout GEM bo in a special way
(until we have our own KMS/DRM kernel driver.. and even then for
phones/tablets you probably need to use the android drivers if you don't
want to port the lcd panel driver support).  The easiest way to handle
this is let the DDX create the scanout bo, and then create the xa
surface from that.

Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
 src/gallium/state_trackers/xa/xa_tracker.c | 41 +++++++++++++++++++++++++++---
 src/gallium/state_trackers/xa/xa_tracker.h |  9 +++++++
 2 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index 3410144..b49f0d9 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -279,13 +279,14 @@ xa_format_check_supported(struct xa_tracker *xa,
     return XA_ERR_NONE;
 }
 
-XA_EXPORT struct xa_surface *
-xa_surface_create(struct xa_tracker *xa,
+static struct xa_surface *
+surface_create(struct xa_tracker *xa,
 		  int width,
 		  int height,
 		  int depth,
 		  enum xa_surface_type stype,
-		  enum xa_formats xa_format, unsigned int flags)
+		  enum xa_formats xa_format, unsigned int flags,
+		  struct winsys_handle *whandle)
 {
     struct pipe_resource *template;
     struct xa_surface *srf;
@@ -320,7 +321,10 @@ xa_surface_create(struct xa_tracker *xa,
     if (flags & XA_FLAG_SCANOUT)
 	template->bind |= PIPE_BIND_SCANOUT;
 
-    srf->tex = xa->screen->resource_create(xa->screen, template);
+    if (whandle)
+	srf->tex = xa->screen->resource_from_handle(xa->screen, template, whandle);
+    else
+	srf->tex = xa->screen->resource_create(xa->screen, template);
     if (!srf->tex)
 	goto out_no_tex;
 
@@ -334,6 +338,35 @@ xa_surface_create(struct xa_tracker *xa,
     return NULL;
 }
 
+
+XA_EXPORT struct xa_surface *
+xa_surface_create(struct xa_tracker *xa,
+		  int width,
+		  int height,
+		  int depth,
+		  enum xa_surface_type stype,
+		  enum xa_formats xa_format, unsigned int flags)
+{
+    return surface_create(xa, width, height, depth, stype, xa_format, flags, NULL);
+}
+
+
+XA_EXPORT struct xa_surface *
+xa_surface_from_handle(struct xa_tracker *xa,
+		  int width,
+		  int height,
+		  int depth,
+		  enum xa_surface_type stype,
+		  enum xa_formats xa_format, unsigned int flags,
+		  uint32_t handle, uint32_t stride)
+{
+    struct winsys_handle whandle;
+    memset(&whandle, 0, sizeof(whandle));
+    whandle.handle = handle;
+    whandle.stride = stride;
+    return surface_create(xa, width, height, depth, stype, xa_format, flags, &whandle);
+}
+
 XA_EXPORT int
 xa_surface_redefine(struct xa_surface *srf,
 		    int width,
diff --git a/src/gallium/state_trackers/xa/xa_tracker.h b/src/gallium/state_trackers/xa/xa_tracker.h
index ffe24f7..1348621 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.h
+++ b/src/gallium/state_trackers/xa/xa_tracker.h
@@ -160,6 +160,15 @@ extern struct xa_surface *xa_surface_create(struct xa_tracker *xa,
 					    enum xa_formats pform,
 					    unsigned int flags);
 
+extern struct xa_surface * xa_surface_from_handle(struct xa_tracker *xa,
+					    int width,
+					    int height,
+					    int depth,
+					    enum xa_surface_type stype,
+					    enum xa_formats pform,
+					    unsigned int flags,
+					    uint32_t handle, uint32_t stride);
+
 enum xa_formats xa_surface_format(const struct xa_surface *srf);
 
 extern void xa_surface_destroy(struct xa_surface *srf);
-- 
1.8.1.4



More information about the mesa-dev mailing list