From 0371a6cfa98e5aa3a132707b7e03784f60ad06d0 Mon Sep 17 00:00:00 2001 From: Naseer Ahmed Date: Thu, 12 Apr 2012 18:49:31 -0400 Subject: [PATCH] display: Use a new flag for content protection The GRALLOC_USAGE_PROTECTED flag that was used earlier for content protection is also used for some other use cases such as disabling of screen captures. Define this new flag that is explicitly used for allocating secured buffers for DRM. Change-Id: Ia33f79fa0dea7f2f16dd320f267203e6173af48e CRs-fixed: 348454 (cherry picked from commit 440a996f13be732895524412762793f109681c11) --- libgralloc/alloc_controller.cpp | 5 +++-- libgralloc/gpu.cpp | 3 ++- libgralloc/gralloc_priv.h | 8 ++++++++ liboverlay/overlayLib.cpp | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp index a8bb57e..a88f214 100644 --- a/libgralloc/alloc_controller.cpp +++ b/libgralloc/alloc_controller.cpp @@ -67,7 +67,8 @@ static bool canFallback(int compositionType, int usage, bool triedSystem) return false; if(triedSystem) return false; - if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_PROTECTED)) + if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_PROTECTED | + GRALLOC_USAGE_PRIVATE_CP_BUFFER)) return false; if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_EXTERNAL_ONLY)) return false; @@ -140,7 +141,7 @@ int IonController::allocate(alloc_data& data, int usage, if(usage & GRALLOC_USAGE_PRIVATE_CAMERA_HEAP) ionFlags |= ION_HEAP(ION_CAMERA_HEAP_ID); - if(usage & GRALLOC_USAGE_PROTECTED) + if(usage & GRALLOC_USAGE_PRIVATE_CP_BUFFER) ionFlags |= ION_SECURE; if(usage & GRALLOC_USAGE_PRIVATE_DO_NOT_MAP) diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp index 7e3d9c2..7832121 100755 --- a/libgralloc/gpu.cpp +++ b/libgralloc/gpu.cpp @@ -234,7 +234,8 @@ int gpu_context_t::alloc_impl(int w, int h, int format, int usage, // All buffers marked as protected or for external // display need to go to overlay if ((usage & GRALLOC_USAGE_EXTERNAL_DISP) || - (usage & GRALLOC_USAGE_PROTECTED)) { + (usage & GRALLOC_USAGE_PROTECTED) || + (usage & GRALLOC_USAGE_PRIVATE_CP_BUFFER)) { bufferType = BUFFER_TYPE_VIDEO; } int err; diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h index 0d1be56..19b03e0 100644 --- a/libgralloc/gralloc_priv.h +++ b/libgralloc/gralloc_priv.h @@ -85,6 +85,14 @@ enum { * other EXTERNAL_ONLY buffers are available. Used during suspend. */ GRALLOC_USAGE_EXTERNAL_BLOCK = 0x00020000, + + /* Use this flag to request content protected buffers. Please note + * that this flag is different from the GRALLOC_USAGE_PROTECTED flag + * which can be used for buffers that are not secured for DRM + * but still need to be protected from screen captures + * 0x00040000 is reserved and these values are subject to change. + */ + GRALLOC_USAGE_PRIVATE_CP_BUFFER = 0x00080000, }; enum { diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index 2d972f2..29e3269 100755 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -1821,7 +1821,7 @@ bool OverlayDataChannel::mapRotatorMemory(int num_buffers, bool uiChannel, int r GRALLOC_USAGE_PRIVATE_DO_NOT_MAP; if(mSecure) { - allocFlags |= GRALLOC_USAGE_PROTECTED; + allocFlags |= GRALLOC_USAGE_PRIVATE_CP_BUFFER; } else { allocFlags |= GRALLOC_USAGE_PRIVATE_ADSP_HEAP | GRALLOC_USAGE_PRIVATE_IOMMU_HEAP;