modesetting: Add drmmode_bo_has_bo and drmmode_bo_map helper function

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Jason Ekstrand 2015-01-13 15:08:36 -08:00 committed by Keith Packard
parent b4703a5a6e
commit 7c656bfcae

View File

@ -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 *