[cairo] [PATCH 37/54] drm: generalized *_bo_map functions
Enrico Weigelt, metux IT consult
enrico.weigelt at gr13.net
Wed Dec 23 02:23:21 PST 2015
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 | 2 ++
src/drm/cairo-drm-radeon-private.h | 8 +++++++-
src/drm/cairo-drm-radeon.c | 5 ++++-
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 c5cb9a7..5ca1070 100644
--- a/src/drm/cairo-drm-intel-private.h
+++ b/src/drm/cairo-drm-intel-private.h
@@ -347,7 +347,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 b656df2..842fde3 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;
@@ -763,6 +766,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 c0e40e4..88b05e7 100644
--- a/src/drm/cairo-drm-private.h
+++ b/src/drm/cairo-drm-private.h
@@ -126,6 +126,8 @@ struct _cairo_drm_device {
cairo_drm_surface_backend_t surface;
cairo_drm_device_backend_t device;
+ void *(*bo_map)(const cairo_drm_device_t *, cairo_drm_bo_t *);
+
cairo_drm_device_t *next, *prev;
};
diff --git a/src/drm/cairo-drm-radeon-private.h b/src/drm/cairo-drm-radeon-private.h
index eeba424..a31fff2 100644
--- a/src/drm/cairo-drm-radeon-private.h
+++ b/src/drm/cairo-drm-radeon-private.h
@@ -180,7 +180,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 6927ac8..90eaa17 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));
--
2.6.4.442.g545299f
More information about the cairo
mailing list