OSDN Git Service

Add support for modifiers
authorRobert Foss <robert.foss@collabora.com>
Thu, 1 Jun 2017 00:39:58 +0000 (20:39 -0400)
committerRob Herring <robherring2@gmail.com>
Thu, 22 Jun 2017 03:29:32 +0000 (22:29 -0500)
Modifiers are used to describe buffer metadata like if and how they are
compressed or if tiling is used.

This is needed to allow different devices to communicate about buffers
that have these properties.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
gralloc_drm_handle.h
gralloc_gbm.cpp

index 7f332b3..8c54308 100644 (file)
@@ -49,6 +49,7 @@ struct gralloc_drm_handle_t {
 
        int name;   /* the name of the bo */
        int stride; /* the stride in bytes */
+       uint64_t modifier; /* buffer modifiers */
 
        int data_owner; /* owner of data (for validation) */
        union {
index ea1035f..40bfb37 100644 (file)
@@ -116,9 +116,13 @@ static struct gralloc_gbm_bo_t *gbm_import(struct gbm_device *gbm,
                struct gralloc_gbm_handle_t *handle)
 {
        struct gralloc_gbm_bo_t *buf;
+       #ifdef GBM_BO_IMPORT_FD_MODIFIER
+       struct gbm_import_fd_modifier_data data;
+       #else
        struct gbm_import_fd_data data;
-       int format = get_gbm_format(handle->format);
+       #endif
 
+       int format = get_gbm_format(handle->format);
        if (handle->prime_fd < 0)
                return NULL;
 
@@ -133,14 +137,18 @@ static struct gralloc_gbm_bo_t *gbm_import(struct gbm_device *gbm,
        data.height = handle->height;
        data.stride = handle->stride;
        data.format = format;
-
        /* Adjust the width and height for a GBM GR88 buffer */
        if (handle->format == HAL_PIXEL_FORMAT_YV12) {
                data.width /= 2;
                data.height += handle->height / 2;
        }
 
+       #ifdef GBM_BO_IMPORT_FD_MODIFIER
+       data.modifier = handle->modifier;
+       buf->bo = gbm_bo_import(gbm, GBM_BO_IMPORT_FD_MODIFIER, &data, 0);
+       #else
        buf->bo = gbm_bo_import(gbm, GBM_BO_IMPORT_FD, &data, 0);
+       #endif
        if (!buf->bo) {
                delete buf;
                return NULL;
@@ -192,6 +200,9 @@ static struct gralloc_gbm_bo_t *gbm_alloc(struct gbm_device *gbm,
 
        handle->prime_fd = gbm_bo_get_fd(buf->bo);
        handle->stride = gbm_bo_get_stride(buf->bo);
+       #ifdef GBM_BO_IMPORT_FD_MODIFIER
+       handle->modifier = gbm_bo_get_modifier(buf->bo);
+       #endif
 
        return buf;
 }