summaryrefslogtreecommitdiffstats
path: root/src/gbm/backends/dri
diff options
context:
space:
mode:
authorJesse Barnes <[email protected]>2012-02-21 12:53:09 -0800
committerJesse Barnes <[email protected]>2012-02-22 09:41:40 -0800
commit8de5c355fa2bf0f30df2c7cf39aee01e793284bf (patch)
tree4001a8ba5a618e607626610532a67fe080f7d8f4 /src/gbm/backends/dri
parentd35d3d612acef1612aaab9a923b8814d4dbb4d9c (diff)
gbm: track buffer format through DRI drivers
GBM needs the buffer format in order to communicate with DRM and clients for things like scanout. So track the DRI format requested in the various back ends and use it to return the DRI format back to GBM when requested. GBM will then map this into the GBM surface type (which is in turn based on the DRM fb format list). Signed-off-by: Jesse Barnes <[email protected]>
Diffstat (limited to 'src/gbm/backends/dri')
-rw-r--r--src/gbm/backends/dri/gbm_dri.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index ddd153a7db4..34f07de4bba 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -216,13 +216,15 @@ free_screen:
static int
gbm_dri_is_format_supported(struct gbm_device *gbm,
- enum gbm_bo_format format,
+ uint32_t format,
uint32_t usage)
{
switch (format) {
case GBM_BO_FORMAT_XRGB8888:
+ case GBM_FORMAT_XRGB8888:
break;
case GBM_BO_FORMAT_ARGB8888:
+ case GBM_FORMAT_ARGB8888:
if (usage & GBM_BO_USE_SCANOUT)
return 0;
break;
@@ -247,6 +249,32 @@ gbm_dri_bo_destroy(struct gbm_bo *_bo)
free(bo);
}
+static uint32_t
+gbm_dri_to_gbm_format(uint32_t dri_format)
+{
+ uint32_t ret = 0;
+
+ switch (dri_format) {
+ case __DRI_IMAGE_FORMAT_RGB565:
+ ret = GBM_FORMAT_RGB565;
+ break;
+ case __DRI_IMAGE_FORMAT_XRGB8888:
+ ret = GBM_FORMAT_XRGB8888;
+ break;
+ case __DRI_IMAGE_FORMAT_ARGB8888:
+ ret = GBM_FORMAT_ARGB8888;
+ break;
+ case __DRI_IMAGE_FORMAT_ABGR8888:
+ ret = GBM_FORMAT_ABGR8888;
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+
+ return ret;
+}
+
static struct gbm_bo *
gbm_dri_bo_create_from_egl_image(struct gbm_device *gbm,
void *egl_dpy, void *egl_img,
@@ -255,6 +283,7 @@ gbm_dri_bo_create_from_egl_image(struct gbm_device *gbm,
{
struct gbm_dri_device *dri = gbm_dri_device(gbm);
struct gbm_dri_bo *bo;
+ int dri_format;
unsigned dri_use = 0;
(void) egl_dpy;
@@ -291,6 +320,10 @@ gbm_dri_bo_create_from_egl_image(struct gbm_device *gbm,
&bo->base.base.handle.s32);
dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_STRIDE,
(int *) &bo->base.base.pitch);
+ dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_FORMAT,
+ &dri_format);
+
+ bo->base.base.format = gbm_dri_to_gbm_format(dri_format);
return &bo->base.base;
}
@@ -298,7 +331,7 @@ gbm_dri_bo_create_from_egl_image(struct gbm_device *gbm,
static struct gbm_bo *
gbm_dri_bo_create(struct gbm_device *gbm,
uint32_t width, uint32_t height,
- enum gbm_bo_format format, uint32_t usage)
+ uint32_t format, uint32_t usage)
{
struct gbm_dri_device *dri = gbm_dri_device(gbm);
struct gbm_dri_bo *bo;
@@ -314,12 +347,20 @@ gbm_dri_bo_create(struct gbm_device *gbm,
bo->base.base.height = height;
switch (format) {
+ case GBM_FORMAT_RGB565:
+ dri_format =__DRI_IMAGE_FORMAT_RGB565;
+ break;
+ case GBM_FORMAT_XRGB8888:
case GBM_BO_FORMAT_XRGB8888:
dri_format = __DRI_IMAGE_FORMAT_XRGB8888;
break;
+ case GBM_FORMAT_ARGB8888:
case GBM_BO_FORMAT_ARGB8888:
dri_format = __DRI_IMAGE_FORMAT_ARGB8888;
break;
+ case GBM_FORMAT_ABGR8888:
+ dri_format = __DRI_IMAGE_FORMAT_ABGR8888;
+ break;
default:
return NULL;
}