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,
diff --git a/libqdutils/qdMetaData.cpp b/libqdutils/qdMetaData.cpp
index de94591..88109c9 100644
--- a/libqdutils/qdMetaData.cpp
+++ b/libqdutils/qdMetaData.cpp
@@ -90,6 +90,9 @@
case UPDATE_COLOR_SPACE:
data->colorSpace = *((ColorSpace_t *)param);
break;
+ case MAP_SECURE_BUFFER:
+ data->mapSecureBuffer = *((int32_t *)param);
+ break;
default:
ALOGE("Unknown paramType %d", paramType);
break;
diff --git a/libqdutils/qdMetaData.h b/libqdutils/qdMetaData.h
index a71ee8b..32d788e 100644
--- a/libqdutils/qdMetaData.h
+++ b/libqdutils/qdMetaData.h
@@ -79,6 +79,13 @@
int64_t timestamp;
uint32_t refreshrate;
enum ColorSpace_t colorSpace;
+ /* Gralloc sets PRIV_SECURE_BUFFER flag to inform that the buffers are from
+ * ION_SECURE. which should not be mapped. However, for GPU post proc
+ * feature, GFX needs to map this buffer, in the client context and in SF
+ * context, it should not. Hence to differentiate, add this metadata field
+ * for clients to set, and GPU will to read and know when to map the
+ * SECURE_BUFFER(ION) */
+ int32_t mapSecureBuffer;
};
enum DispParamType {
@@ -92,6 +99,7 @@
UPDATE_BUFFER_GEOMETRY = 0x0080,
UPDATE_REFRESH_RATE = 0x0100,
UPDATE_COLOR_SPACE = 0x0200,
+ MAP_SECURE_BUFFER = 0x400,
};
struct private_handle_t;