gralloc: Make all secure heaps and flags backward compatible
Make all content protection and secure display heaps and flags
backward compatible. Honor the different requirements for master
side and slave side content protection and secure display.
Change-Id: I21a5170f2ae7ffd9c447e8af795e3665e673248f
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index b8e6a64..c052ffb 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -49,17 +49,28 @@
#define ASTC_BLOCK_SIZE 16
-#ifdef ION_FLAG_CP_PIXEL
-#define CP_HEAP_ID ION_SECURE_HEAP_ID
-#else
+#ifndef ION_FLAG_CP_PIXEL
#define ION_FLAG_CP_PIXEL 0
-#define CP_HEAP_ID ION_CP_MM_HEAP_ID
#endif
#ifndef ION_FLAG_ALLOW_NON_CONTIG
#define ION_FLAG_ALLOW_NON_CONTIG 0
#endif
+#ifdef MASTER_SIDE_CP
+#define CP_HEAP_ID ION_SECURE_HEAP_ID
+/* Please Add the new SD ION Heap here */
+#define SD_HEAP_ID 0
+#define ION_CP_FLAGS (ION_SECURE | ION_FLAG_CP_PIXEL)
+/* Please Add the new SD ION Flag here */
+#define ION_SD_FLAGS ION_SECURE
+#else // SLAVE_SIDE_CP
+#define CP_HEAP_ID ION_CP_MM_HEAP_ID
+#define SD_HEAP_ID CP_HEAP_ID
+#define ION_CP_FLAGS (ION_SECURE | ION_FLAG_ALLOW_NON_CONTIG)
+#define ION_SD_FLAGS ION_SECURE
+#endif
+
using namespace gralloc;
using namespace qdutils;
@@ -347,21 +358,16 @@
if(usage & GRALLOC_USAGE_PROTECTED) {
if (usage & GRALLOC_USAGE_PRIVATE_MM_HEAP) {
- ionHeapId = ION_HEAP(CP_HEAP_ID);
- ionFlags |= ION_SECURE;
if (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY) {
+ ionHeapId = ION_HEAP(SD_HEAP_ID);
/*
* There is currently no flag in ION for Secure Display
- * VM. Please add it here once available.
- *
- ionFlags |= <Ion flag for Secure Display>;
+ * VM. Please add it to the define once available.
*/
+ ionFlags |= ION_SD_FLAGS;
} else {
- ionFlags |= ION_FLAG_CP_PIXEL;
- }
-
- if (!(usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY)) {
- ionFlags |= ION_FLAG_ALLOW_NON_CONTIG;
+ ionHeapId = ION_HEAP(CP_HEAP_ID);
+ ionFlags |= ION_CP_FLAGS;
}
} else {
// for targets/OEMs which do not need HW level protection