[cairo] [PATCH v8 39/71] drm: generalized *_bo_map functions

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Thu Jun 30 15:46:17 UTC 2016


Signed-off-by: Enrico Weigelt, metux IT consult <enrico.weigelt at gr13.net>
---
 src/drm/cairo-drm-intel-private.h  | 8 +++++++-
 src/drm/cairo-drm-intel.c          | 6 +++++-
 src/drm/cairo-drm-private.h        | 1 +
 src/drm/cairo-drm-radeon-private.h | 8 +++++++-
 src/drm/cairo-drm-radeon.c         | 6 +++++-
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/drm/cairo-drm-intel-private.h b/src/drm/cairo-drm-intel-private.h
index 3e53733..4d3b7c1 100644
--- a/src/drm/cairo-drm-intel-private.h
+++ b/src/drm/cairo-drm-intel-private.h
@@ -346,7 +346,13 @@ intel_bo_read (const intel_device_t *dev,
 	       void *data);
 
 cairo_private void *
-intel_bo_map (const intel_device_t *dev, intel_bo_t *bo);
+_cairo_drm_intel_bo_map (const cairo_drm_device_t *dev, cairo_drm_bo_t *bo);
+
+static inline void *
+intel_bo_map (const intel_device_t *dev, intel_bo_t *bo)
+{
+    return dev->base.bo.map (&dev->base, &bo->base);
+}
 
 cairo_private cairo_status_t
 intel_bo_init (const intel_device_t *dev,
diff --git a/src/drm/cairo-drm-intel.c b/src/drm/cairo-drm-intel.c
index 86876e6..515eec9 100644
--- a/src/drm/cairo-drm-intel.c
+++ b/src/drm/cairo-drm-intel.c
@@ -155,8 +155,11 @@ intel_bo_read (const intel_device_t *device,
 }
 
 void *
-intel_bo_map (const intel_device_t *device, intel_bo_t *bo)
+_cairo_drm_intel_bo_map (const cairo_drm_device_t *drm_dev, cairo_drm_bo_t *drm_bo)
 {
+    const intel_device_t *device = _cairo_drm_device_cast_intel_const (drm_dev);
+    intel_bo_t *bo = _cairo_drm_bo_cast_intel (drm_bo);
+
     struct drm_i915_gem_set_domain set_domain;
     uint32_t domain;
     int ret;
@@ -718,6 +721,7 @@ intel_device_init (intel_device_t *device, int fd)
     device->gradient_cache.size = 0;
 
     device->base.bo.release = intel_bo_release;
+    device->base.bo.map     = _cairo_drm_intel_bo_map;
 
     return CAIRO_STATUS_SUCCESS;
 }
diff --git a/src/drm/cairo-drm-private.h b/src/drm/cairo-drm-private.h
index 800d159..90cd54c 100644
--- a/src/drm/cairo-drm-private.h
+++ b/src/drm/cairo-drm-private.h
@@ -92,6 +92,7 @@ typedef cairo_surface_t *
 
 typedef struct _cairo_drm_bo_backend {
     void (*release) (cairo_drm_device_t *device, cairo_drm_bo_t *bo);
+    void *(*map)    (const cairo_drm_device_t *device, cairo_drm_bo_t *bo);
 } cairo_drm_bo_backend_t;
 
 typedef struct _cairo_drm_device_backend {
diff --git a/src/drm/cairo-drm-radeon-private.h b/src/drm/cairo-drm-radeon-private.h
index 561518c..c2234fc 100644
--- a/src/drm/cairo-drm-radeon-private.h
+++ b/src/drm/cairo-drm-radeon-private.h
@@ -175,7 +175,13 @@ cairo_private void
 radeon_bo_wait (const radeon_device_t *dev, radeon_bo_t *bo);
 
 cairo_private void *
-radeon_bo_map (const radeon_device_t *dev, radeon_bo_t *bo);
+_cairo_drm_radeon_bo_map (const cairo_drm_device_t *dev, cairo_drm_bo_t *bo);
+
+static inline void *
+radeon_bo_map (const radeon_device_t *dev, radeon_bo_t *bo)
+{
+    return dev->base.bo.map (&dev->base, &bo->base);
+}
 
 cairo_private cairo_drm_bo_t *
 radeon_bo_create (radeon_device_t *dev,
diff --git a/src/drm/cairo-drm-radeon.c b/src/drm/cairo-drm-radeon.c
index 409c75e..2ef53d1 100644
--- a/src/drm/cairo-drm-radeon.c
+++ b/src/drm/cairo-drm-radeon.c
@@ -138,12 +138,15 @@ radeon_bo_wait (const radeon_device_t *device, radeon_bo_t *bo)
 }
 
 void *
-radeon_bo_map (const radeon_device_t *device, radeon_bo_t *bo)
+_cairo_drm_radeon_bo_map (const cairo_drm_device_t *drm_dev, cairo_drm_bo_t *drm_bo)
 {
     struct drm_radeon_gem_mmap mmap_arg;
     void *ptr;
     int ret;
 
+    const radeon_device_t* device = _cairo_drm_device_cast_radeon_const (drm_dev);
+    radeon_bo_t *bo = _cairo_drm_bo_cast_radeon (drm_bo);
+
     assert (bo->base.mapped == NULL);
 
     memset (&mmap_arg, 0, sizeof (mmap_arg));
@@ -294,6 +297,7 @@ radeon_device_init (radeon_device_t *device, int fd)
     _cairo_freepool_init (&device->base.bo_pool, sizeof (radeon_bo_t));
 
     device->base.bo.release = radeon_bo_release;
+    device->base.bo.map     = _cairo_drm_radeon_bo_map;
 
     return CAIRO_STATUS_SUCCESS;
 }
-- 
2.6.4.442.g545299f



More information about the cairo mailing list