summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Foss <robert.foss@collabora.com>2017-05-31 20:39:58 -0400
committerRobert Foss <robert.foss@collabora.com>2017-06-08 13:30:16 -0400
commit07f1aed0dad760a501315f1a30c5c2c7ec0bc210 (patch)
tree01211249a05e50c9d4e6ccacae180261d3707978
parent75371e8b2991c5e6447ab3acb177c981ca7d67f3 (diff)
downloadgbm_gralloc-07f1aed0dad760a501315f1a30c5c2c7ec0bc210.tar.gz
Add support for modifiers
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>
-rw-r--r--gralloc_drm_handle.h1
-rw-r--r--gralloc_gbm.cpp15
2 files changed, 14 insertions, 2 deletions
diff --git a/gralloc_drm_handle.h b/gralloc_drm_handle.h
index 5c8d925..cd31cdf 100644
--- a/gralloc_drm_handle.h
+++ b/gralloc_drm_handle.h
@@ -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 {
diff --git a/gralloc_gbm.cpp b/gralloc_gbm.cpp
index 3bfe45a..990cc3f 100644
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -102,9 +102,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;
@@ -119,14 +123,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;
@@ -178,6 +186,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;
}