gralloc/qdMetadata: Add mapSecureBuffer field to metadata struct
- The client sets this metadata to inform GPU to map the CP buffer
- GPU will check the PRIV_FLAG_SECURE and this metadata to map the CP buffer
- If this field is not set on the buffer handle, then GPU will not map
the CP buffer
- Allow mapping of metadata for SECURE_BUFFERS also
Change-Id: I86300a1b4e3008f9d0884940420e9036c47a016f
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index 5ba737a..943e64f 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -63,12 +63,15 @@
return -EINVAL;
private_handle_t* hnd = (private_handle_t*)handle;
+ unsigned int size = 0;
+ int err = 0;
+ IMemAlloc* memalloc = getAllocator(hnd->flags) ;
void *mappedAddress;
+ // Dont map FRAMEBUFFER and SECURE_BUFFERS
if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER) &&
!(hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)) {
- unsigned int size = hnd->size;
- IMemAlloc* memalloc = getAllocator(hnd->flags) ;
- int err = memalloc->map_buffer(&mappedAddress, size,
+ size = hnd->size;
+ err = memalloc->map_buffer(&mappedAddress, size,
hnd->offset, hnd->fd);
if(err || mappedAddress == MAP_FAILED) {
ALOGE("Could not mmap handle %p, fd=%d (%s)",
@@ -78,6 +81,10 @@
}
hnd->base = uint64_t(mappedAddress) + hnd->offset;
+ }
+
+ //Allow mapping of metadata for all buffers and SECURE_BUFFER
+ if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) {
mappedAddress = MAP_FAILED;
size = ROUND_UP_PAGESIZE(sizeof(MetaData_t));
err = memalloc->map_buffer(&mappedAddress, size,