gralloc: Notify ION driver about CDSP buffer access

Set the ION flag ION_FLAG_CP_CDSP to notify the CDSP buffer access

Change-Id: I7f61b972f67c1def8edfa23456f18563ac46da68
diff --git a/gralloc/gr_allocator.cpp b/gralloc/gr_allocator.cpp
index 4c16b62..fc53168 100644
--- a/gralloc/gr_allocator.cpp
+++ b/gralloc/gr_allocator.cpp
@@ -54,6 +54,10 @@
 #define ION_SECURE ION_FLAG_SECURE
 #endif
 
+#ifndef ION_FLAG_CP_CDSP
+#define ION_FLAG_CP_CDSP 0
+#endif
+
 #ifdef SLAVE_SIDE_CP
 #define CP_HEAP_ID ION_CP_MM_HEAP_ID
 #define SD_HEAP_ID CP_HEAP_ID
@@ -206,11 +210,17 @@
       flags |= UINT(ION_SD_FLAGS);
     } else if (usage & BufferUsage::CAMERA_OUTPUT) {
       heap_id = ION_HEAP(SD_HEAP_ID);
+      if (usage & GRALLOC_USAGE_PRIVATE_CDSP) {
+        flags |= UINT(ION_SECURE | ION_FLAG_CP_CDSP);
+      }
       if (usage & BufferUsage::COMPOSER_OVERLAY) {
         flags |= UINT(ION_SC_PREVIEW_FLAGS);
       } else {
         flags |= UINT(ION_SC_FLAGS);
       }
+    } else if (usage & GRALLOC_USAGE_PRIVATE_CDSP) {
+      heap_id = ION_HEAP(ION_SECURE_CARVEOUT_HEAP_ID);
+      flags |= UINT(ION_SECURE | ION_FLAG_CP_CDSP);
     } else {
       heap_id = ION_HEAP(CP_HEAP_ID);
       flags |= UINT(ION_CP_FLAGS);
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index 075a6e4..f9338d6 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -83,6 +83,9 @@
 /* This flag indicates PI format is being used */
 #define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI 1ULL << 49
 
+/* This flag is set while CDSP accesses the buffer */
+#define GRALLOC_USAGE_PRIVATE_CDSP 1ULL << 50
+
 /* Legacy gralloc1 definitions */
 /* Some clients may still be using the old flags */
 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_ADSP_HEAP GRALLOC_USAGE_PRIVATE_ADSP_HEAP