external/gbm_gralloc
Revision | cfc6f0613c16e9bc888a4e6378e5900e3bcefdfa (tree) |
---|---|
Time | 2016-04-23 02:52:45 |
Author | Rob Herring <robh@kern...> |
Commiter | Rob Herring |
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>
@@ -32,6 +32,7 @@ | ||
32 | 32 | #include <sys/types.h> |
33 | 33 | #include <sys/stat.h> |
34 | 34 | #include <fcntl.h> |
35 | +#include <assert.h> | |
35 | 36 | |
36 | 37 | #include <hardware/gralloc.h> |
37 | 38 | #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, | ||
193 | 194 | int enable_write, void **addr) |
194 | 195 | { |
195 | 196 | int err = 0; |
197 | + int flags = GBM_BO_TRANSFER_READ; | |
198 | + uint32_t stride; | |
196 | 199 | |
197 | 200 | if (bo->map_data) |
198 | 201 | return -EINVAL; |
199 | 202 | |
200 | - *addr = gbm_bo_map(bo->bo, x, y, w, h, 0, &bo->map_data); | |
203 | + if (enable_write) | |
204 | + flags |= GBM_BO_TRANSFER_WRITE; | |
205 | + | |
206 | + *addr = gbm_bo_map(bo->bo, x, y, w, h, flags, &stride, &bo->map_data); | |
201 | 207 | ALOGE("mapped bo %p at %p", bo, *addr); |
202 | 208 | if (*addr == NULL) |
203 | - err = -ENOMEM; | |
209 | + return -ENOMEM; | |
210 | + | |
211 | + assert(stride == gbm_bo_get_stride(bo)); | |
204 | 212 | |
205 | 213 | return err; |
206 | 214 | } |