summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2016-04-22 12:50:35 -0500
committerRob Herring <robh@kernel.org>2016-04-22 12:50:35 -0500
commit2004d793a40781d533250c2e6a1b6a8e88c31622 (patch)
tree0cefff862241ee68cf3877bfe3997b9a8719e4f4
parentf6a33583e7ac19ef5a3f1d104b768ecd471fa851 (diff)
downloadgbm_gralloc-2004d793a40781d533250c2e6a1b6a8e88c31622.tar.gz
gbm_gralloc-2004d793a40781d533250c2e6a1b6a8e88c31622.tar.xz
Update usage flag handling
Add missing support for GRALLOC_USAGE_SW_READ_OFTEN, GRALLOC_USAGE_SW_WRITE_OFTEN, GRALLOC_USAGE_HW_TEXTURE, and GRALLOC_USAGE_CURSOR usage flags mapping them to GBM flags. For now, cursor flag is commented out because the Android side doesn't seem to honor a larger stride. Signed-off-by: Rob Herring <robh@kernel.org>
-rw-r--r--gralloc_gbm.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/gralloc_gbm.cpp b/gralloc_gbm.cpp
index 115aa8c..265d1eb 100644
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -92,22 +92,18 @@ static uint32_t get_gbm_format(int format)
return fmt;
}
-static unsigned get_pipe_bind(int usage)
+static unsigned int get_pipe_bind(int usage)
{
- unsigned bind = 0;
-#if 0
- if (usage & GRALLOC_USAGE_SW_READ_MASK)
- bind |= PIPE_BIND_TRANSFER_READ;
- if (usage & GRALLOC_USAGE_SW_WRITE_MASK)
- bind |= PIPE_BIND_TRANSFER_WRITE;
- if (usage & GRALLOC_USAGE_HW_TEXTURE)
- bind |= PIPE_BIND_SAMPLER_VIEW;
-#endif
- if (usage & GRALLOC_USAGE_HW_RENDER)
+ unsigned int bind = 0;
+
+ if (usage & (GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN))
+ bind |= GBM_BO_USE_LINEAR;
+ if (usage & GRALLOC_USAGE_CURSOR)
+ ;//bind |= GBM_BO_USE_CURSOR;
+ if (usage & (GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE))
bind |= GBM_BO_USE_RENDERING;
- if (usage & GRALLOC_USAGE_HW_FB) {
+ if (usage & GRALLOC_USAGE_HW_FB)
bind |= GBM_BO_USE_SCANOUT;
- }
return bind;
}
@@ -149,6 +145,7 @@ static struct gralloc_gbm_bo_t *gbm_alloc(struct gbm_device *gbm,
struct gralloc_gbm_bo_t *buf;
int format = get_gbm_format(handle->format);
int usage = get_pipe_bind(handle->usage);
+ int width, height;
buf = new struct gralloc_gbm_bo_t();
if (!buf) {
@@ -156,8 +153,21 @@ static struct gralloc_gbm_bo_t *gbm_alloc(struct gbm_device *gbm,
return NULL;
}
- buf->bo = gbm_bo_create(gbm, handle->width, handle->height, format, usage);
+ width = handle->width;
+ height = handle->height;
+ if (usage & GBM_BO_USE_CURSOR) {
+ if (handle->width < 64)
+ width = 64;
+ if (handle->height < 64)
+ height = 64;
+ }
+
+ ALOGD("create BO, size=%dx%d, fmt=%d, usage=%x",
+ handle->width, handle->height, handle->format, usage);
+ buf->bo = gbm_bo_create(gbm, width, height, format, usage);
if (!buf->bo) {
+ ALOGE("failed to create BO, size=%dx%d, fmt=%d, usage=%x",
+ handle->width, handle->height, handle->format, usage);
delete buf;
return NULL;
}