[PATCH 4/6] dri/intel: Add intel_fd_for_region

Keith Packard keithp at keithp.com
Fri Nov 1 00:13:14 CET 2013


Returns a prime file descriptor for the specified region.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 src/mesa/drivers/dri/i915/intel_regions.c | 13 +++++++++++++
 src/mesa/drivers/dri/i915/intel_regions.h |  4 ++++
 src/mesa/drivers/dri/i965/intel_regions.c | 13 +++++++++++++
 src/mesa/drivers/dri/i965/intel_regions.h |  4 ++++
 4 files changed, 34 insertions(+)

diff --git a/src/mesa/drivers/dri/i915/intel_regions.c b/src/mesa/drivers/dri/i915/intel_regions.c
index 9f5b89e..bac997d 100644
--- a/src/mesa/drivers/dri/i915/intel_regions.c
+++ b/src/mesa/drivers/dri/i915/intel_regions.c
@@ -238,6 +238,19 @@ intel_region_alloc_for_fd(struct intel_screen *screen,
    return region;
 }
 
+int
+intel_fd_for_region(struct intel_screen *screen,
+                    struct intel_region *region)
+{
+   int  fd;
+   int  ret;
+
+   ret = drm_intel_bo_gem_export_to_prime(region->bo, &fd);
+   if (ret < 0)
+      return ret;
+   return fd;
+}
+
 void
 intel_region_reference(struct intel_region **dst, struct intel_region *src)
 {
diff --git a/src/mesa/drivers/dri/i915/intel_regions.h b/src/mesa/drivers/dri/i915/intel_regions.h
index 6bc4a42..84c013a 100644
--- a/src/mesa/drivers/dri/i915/intel_regions.h
+++ b/src/mesa/drivers/dri/i915/intel_regions.h
@@ -93,6 +93,10 @@ intel_region_alloc_for_fd(struct intel_screen *screen,
                           GLuint width, GLuint height, GLuint pitch,
                           GLuint size, int fd, const char *name);
 
+int
+intel_fd_for_region(struct intel_screen *screen,
+                    struct intel_region *region);
+
 bool
 intel_region_flink(struct intel_region *region, uint32_t *name);
 
diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c
index 3920f4f..2e70326 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.c
+++ b/src/mesa/drivers/dri/i965/intel_regions.c
@@ -238,6 +238,19 @@ intel_region_alloc_for_fd(struct intel_screen *screen,
    return region;
 }
 
+int
+intel_fd_for_region(struct intel_screen *screen,
+                    struct intel_region *region)
+{
+   int  fd;
+   int  ret;
+
+   ret = drm_intel_bo_gem_export_to_prime(region->bo, &fd);
+   if (ret < 0)
+      return ret;
+   return fd;
+}
+
 void
 intel_region_reference(struct intel_region **dst, struct intel_region *src)
 {
diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h
index 05dfef3..f471b94 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.h
+++ b/src/mesa/drivers/dri/i965/intel_regions.h
@@ -95,6 +95,10 @@ intel_region_alloc_for_fd(struct intel_screen *screen,
                           GLuint size,
                           int fd, const char *name);
 
+int
+intel_fd_for_region(struct intel_screen *screen,
+                    struct intel_region *region);
+
 bool
 intel_region_flink(struct intel_region *region, uint32_t *name);
 
-- 
1.8.4.2


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
--
_______________________________________________
Dri-devel mailing list
Dri-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel


More information about the dri-devel mailing list