From 4fddb2ba21add1c1968330e5224ecead59da3995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 2 May 2012 15:30:13 -0400 Subject: gbm: Add gbm_bo_write entry point This new gbm entry point allows writing data into a gbm bo. The bo has to be created with the GBM_BO_USE_WRITE flag, and it's only required to work for GBM_BO_USE_CURSOR_64X64 bos. The gbm API is designed to be the glue layer between EGL and KMS, but there was never a mechanism initialize a buffer suitable for use with KMS hw cursors. The hw cursor bo is typically not compatible with anything EGL can render to, and thus there's no way to get data into such a bo. gbm_bo_write() fills that gap while staying out of the efficient cpu->gpu pixel transfer business. Reviewed-by: Ander Conselvan de Oliveira --- src/gbm/backends/dri/gbm_dri.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/gbm/backends') diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 4df6e8f..e5ddfb6 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -291,6 +291,18 @@ gbm_dri_is_format_supported(struct gbm_device *gbm, return 1; } +static int +gbm_dri_bo_write(struct gbm_bo *_bo, const void *buf, size_t count) +{ + struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm); + struct gbm_dri_bo *bo = gbm_dri_bo(_bo); + + if (dri->image->base.version < 4) + return -1; + + return dri->image->write(bo->image, buf, count); +} + static void gbm_dri_bo_destroy(struct gbm_bo *_bo) { @@ -390,6 +402,9 @@ gbm_dri_bo_create(struct gbm_device *gbm, int dri_format; unsigned dri_use = 0; + if (dri->image->base.version < 4 && (usage & GBM_BO_USE_WRITE)) + return NULL; + bo = calloc(1, sizeof *bo); if (bo == NULL) return NULL; @@ -421,6 +436,8 @@ gbm_dri_bo_create(struct gbm_device *gbm, dri_use |= __DRI_IMAGE_USE_SCANOUT; if (usage & GBM_BO_USE_CURSOR_64X64) dri_use |= __DRI_IMAGE_USE_CURSOR; + if (usage & GBM_BO_USE_WRITE) + dri_use |= __DRI_IMAGE_USE_WRITE; bo->image = dri->image->createImage(dri->screen, @@ -491,6 +508,7 @@ dri_device_create(int fd) dri->base.base.bo_create = gbm_dri_bo_create; dri->base.base.bo_create_from_egl_image = gbm_dri_bo_create_from_egl_image; dri->base.base.is_format_supported = gbm_dri_is_format_supported; + dri->base.base.bo_write = gbm_dri_bo_write; dri->base.base.bo_destroy = gbm_dri_bo_destroy; dri->base.base.destroy = dri_destroy; dri->base.base.surface_create = gbm_dri_surface_create; -- cgit v1.1