summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2016-04-22 12:52:45 -0500
committerRob Herring <robh@kernel.org>2016-04-22 12:52:45 -0500
commitcfc6f0613c16e9bc888a4e6378e5900e3bcefdfa (patch)
tree380b90690cf070d026ef23bdde0902ec258524f8
parent2004d793a40781d533250c2e6a1b6a8e88c31622 (diff)
downloadgbm_gralloc-cfc6f0613c16e9bc888a4e6378e5900e3bcefdfa.tar.gz
gbm_gralloc-cfc6f0613c16e9bc888a4e6378e5900e3bcefdfa.tar.xz
gbm_map: update to revised gbm_bo_map API
Add stride return parameter and properly pass usage flags. Signed-off-by: Rob Herring <robh@kernel.org>
-rw-r--r--gralloc_gbm.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/gralloc_gbm.cpp b/gralloc_gbm.cpp
index 265d1eb..eeb637a 100644
--- a/gralloc_gbm.cpp
+++ b/gralloc_gbm.cpp
@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <assert.h>
#include <hardware/gralloc.h>
#include <system/graphics.h>
@@ -193,14 +194,21 @@ static int gbm_map(struct gralloc_gbm_bo_t *bo, int x, int y, int w, int h,
int enable_write, void **addr)
{
int err = 0;
+ int flags = GBM_BO_TRANSFER_READ;
+ uint32_t stride;
if (bo->map_data)
return -EINVAL;
- *addr = gbm_bo_map(bo->bo, x, y, w, h, 0, &bo->map_data);
+ if (enable_write)
+ flags |= GBM_BO_TRANSFER_WRITE;
+
+ *addr = gbm_bo_map(bo->bo, x, y, w, h, flags, &stride, &bo->map_data);
ALOGE("mapped bo %p at %p", bo, *addr);
if (*addr == NULL)
- err = -ENOMEM;
+ return -ENOMEM;
+
+ assert(stride == gbm_bo_get_stride(bo));
return err;
}