Gralloc: Move GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI to lower 32 bits

1) Move GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI to bit 30. Custom formats
like HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS and
HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC can now be used directly without
needing gralloc flags to be set therby freeing bit 27 and bit 30.
2) Add PRIV_FLAGS_SECURE_BUFFER and PRIV_FLAGS_USES_ION to
GetCustomFormatFlags API.

Change-Id: Iee14af2f1a3774ef9922aa380c204ca5ebf60147
CRs-Fixed: 2255171
diff --git a/gralloc/gr_utils.cpp b/gralloc/gr_utils.cpp
index 7c480dc..d91da92 100644
--- a/gralloc/gr_utils.cpp
+++ b/gralloc/gr_utils.cpp
@@ -1116,18 +1116,7 @@
   if (format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED ||
       format == HAL_PIXEL_FORMAT_YCbCr_420_888) {
     if (usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC || usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI) {
-      // Use of 10BIT_TP and 10BIT bits is supposed to be mutually exclusive.
-      // Each bit maps to only one format. Here we will check one of the bits
-      // and ignore the other.
-      if (usage & GRALLOC_USAGE_PRIVATE_10BIT_TP) {
-        gr_format = HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC;
-      } else if (usage & GRALLOC_USAGE_PRIVATE_10BIT) {
-        gr_format = HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC;
-      } else {
-        gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC;
-      }
-    } else if (usage & GRALLOC_USAGE_PRIVATE_10BIT) {
-      gr_format = HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS;
+      gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC;
     } else if (usage & BufferUsage::VIDEO_ENCODER) {
       if (usage & GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER) {
         gr_format = HAL_PIXEL_FORMAT_NV21_ENCODEABLE;  // NV21
@@ -1165,6 +1154,12 @@
   *custom_format = GetImplDefinedFormat(usage, format);
   *priv_flags = GetHandleFlags(*custom_format, usage);
 
+  if (usage & GRALLOC_USAGE_PROTECTED) {
+    *priv_flags |= private_handle_t::PRIV_FLAGS_SECURE_BUFFER;
+  }
+
+  *priv_flags |= private_handle_t::PRIV_FLAGS_USES_ION;
+
   return 0;
 }
 
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index 8f8c0c4..c1af858 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -49,7 +49,10 @@
 #define GRALLOC_USAGE_PRIVATE_UNCACHED (UINT32_C(1) << 29)
 
 /* This flag is used to indicate P010 format */
-#define GRALLOC_USAGE_PRIVATE_10BIT (UINT32_C(1) << 30)
+#define GRALLOC_USAGE_PRIVATE_10BIT 0
+
+/* This flag indicates PI format is being used */
+#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI (UINT32_C(1) << 30)
 
 /* This flag is used for SECURE display usecase */
 #define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY (UINT32_C(1) << 31)
@@ -67,10 +70,8 @@
 #define GRALLOC_USAGE_PRIVATE_WFD (UINT32_C(1) << 21)
 
 /* This flag is used to indicate 10-bit tight pack format (e.g. TP10) */
-#define GRALLOC_USAGE_PRIVATE_10BIT_TP (UINT32_C(1) << 27)
+#define GRALLOC_USAGE_PRIVATE_10BIT_TP 0
 
-/* This flag indicates PI format is being used */
-#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI 1ULL << 49
 /* Legacy gralloc1 definitions */
 /* Some clients may still be using the old flags */
 #define GRALLOC1_PRODUCER_USAGE_PRIVATE_ADSP_HEAP GRALLOC_USAGE_PRIVATE_ADSP_HEAP