[PATCH v3 2/4] modesetting: Add drmmode_bo_has_bo and drmmode_bo_map helper function
Jason Ekstrand
jason at jlekstrand.net
Tue Jan 13 15:08:36 PST 2015
Signed-off-by: Jason Ekstrand <jason.ekstrand at intel.com>
---
hw/xfree86/drivers/modesetting/drmmode_display.c | 43 ++++++++++++++++++------
1 file changed, 32 insertions(+), 11 deletions(-)
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index ea59ffe..ee7087b 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -82,6 +82,17 @@ drmmode_bo_get_pitch(drmmode_bo *bo)
return bo->dumb->pitch;
}
+static Bool
+drmmode_bo_has_bo(drmmode_bo *bo)
+{
+#ifdef GLAMOR_HAS_GBM
+ if (bo->gbm)
+ return TRUE;
+#endif
+
+ return bo->dumb != NULL;
+}
+
uint32_t
drmmode_bo_get_handle(drmmode_bo *bo)
{
@@ -93,6 +104,26 @@ drmmode_bo_get_handle(drmmode_bo *bo)
return bo->dumb->handle;
}
+static void *
+drmmode_bo_map(drmmode_ptr drmmode, drmmode_bo *bo)
+{
+ int ret;
+
+#ifdef GLAMOR_HAS_GBM
+ if (bo->gbm)
+ return NULL;
+#endif
+
+ if (bo->dumb->ptr)
+ return bo->dumb->ptr;
+
+ ret = dumb_bo_map(drmmode->fd, bo->dumb);
+ if (ret)
+ return NULL;
+
+ return bo->dumb->ptr;
+}
+
static Bool
drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
unsigned width, unsigned height, unsigned bpp)
@@ -1570,17 +1601,7 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
void *
drmmode_map_front_bo(drmmode_ptr drmmode)
{
- int ret;
-
- if (drmmode->front_bo.dumb->ptr)
- return drmmode->front_bo.dumb->ptr;
-
- ret = dumb_bo_map(drmmode->fd, drmmode->front_bo.dumb);
- if (ret)
- return NULL;
-
- return drmmode->front_bo.dumb->ptr;
-
+ return drmmode_bo_map(drmmode, &drmmode->front_bo);
}
void *
--
2.2.0
More information about the xorg-devel
mailing list