gralloc: add private flag to indicate chroma space

Bug: 7985212
Change-Id: I1f1205040a72438246246775d57508af16ba1dbd
diff --git a/gralloc/gralloc.cpp b/gralloc/gralloc.cpp
index 2c12bda..cdfa70f 100644
--- a/gralloc/gralloc.cpp
+++ b/gralloc/gralloc.cpp
@@ -300,6 +300,16 @@
                                         *stride, luma_vstride);
         }
     }
+    // Set chroma & gamut fields
+    if (!err && *hnd) {
+        if (usage & GRALLOC_USAGE_PRIVATE_CHROMA) {
+            (*hnd)->chroma = HAL_PIXEL_CHROMA_BT601_8;
+            (*hnd)->gamut = HAL_PIXEL_GAMUT_NARROW_8;
+        } else {
+            (*hnd)->chroma = HAL_PIXEL_CHROMA_BT709_8;
+            (*hnd)->gamut = HAL_PIXEL_GAMUT_WIDE_8;
+        }
+    }
     return err;
 
 err2:
diff --git a/include/gralloc_priv.h b/include/gralloc_priv.h
index 6dd1597..bf2940e 100644
--- a/include/gralloc_priv.h
+++ b/include/gralloc_priv.h
@@ -65,6 +65,9 @@
     struct native_handle nativeHandle;
 #endif
 
+// set if using video encoding colorspace
+#define GRALLOC_USAGE_PRIVATE_CHROMA (GRALLOC_USAGE_PRIVATE_0)
+
     enum {
         PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
         PRIV_FLAGS_USES_UMP    = 0x00000002,