hwc: Add support for external-only layers

Add support for different types of external-only layers
EXTERNAL_ONLY: General purpose
EXTERNAL_BLOCK: Blocks the display of other ext-only layers
EXTERNAL_CC: Used for closed captions with videos.

Change-Id: I9cc7b9a1dbf1085194725474d6a4d1094e27a0c8
Acked-by: Saurabh Shah <saurshah@codeaurora.org>
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 97255ba..e4d1d68 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -57,7 +57,7 @@
     if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_PROTECTED |
                 GRALLOC_USAGE_PRIVATE_CP_BUFFER))
         return false;
-    if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_EXTERNAL_ONLY))
+    if(usage & (GRALLOC_HEAP_MASK | GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY))
         return false;
     //Return true by default
     return true;
diff --git a/libgralloc/gpu.cpp b/libgralloc/gpu.cpp
index b72320b..2db6274 100644
--- a/libgralloc/gpu.cpp
+++ b/libgralloc/gpu.cpp
@@ -142,11 +142,13 @@
         flags |= private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED;
     }
 
-    if (usage & GRALLOC_USAGE_EXTERNAL_ONLY) {
+    if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY) {
         flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_ONLY;
         //The EXTERNAL_BLOCK flag is always an add-on
-        if (usage & GRALLOC_USAGE_EXTERNAL_BLOCK) {
+        if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK) {
             flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_BLOCK;
+        }if (usage & GRALLOC_USAGE_PRIVATE_EXTERNAL_CC) {
+            flags |= private_handle_t::PRIV_FLAGS_EXTERNAL_CC;
         }
     }
 
diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h
index 8f411dc..fa1fe6e 100644
--- a/libgralloc/gralloc_priv.h
+++ b/libgralloc/gralloc_priv.h
@@ -60,20 +60,22 @@
     GRALLOC_USAGE_PRIVATE_UNSYNCHRONIZED  =       0X04000000,
 
     /* Buffer content should be displayed on an external display only */
-    GRALLOC_USAGE_EXTERNAL_ONLY           =       0x08000000,
+    GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY   =       0x08000000,
 
     /* Only this buffer content should be displayed on external, even if
      * other EXTERNAL_ONLY buffers are available. Used during suspend.
      */
-    GRALLOC_USAGE_EXTERNAL_BLOCK          =       0x00100000,
+    GRALLOC_USAGE_PRIVATE_EXTERNAL_BLOCK  =       0x00100000,
+
+    /* Close Caption displayed on an external display only */
+    GRALLOC_USAGE_PRIVATE_EXTERNAL_CC     =       0x00200000,
 
     /* 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       =       0x00200000,
+    GRALLOC_USAGE_PRIVATE_CP_BUFFER       =       0x00400000,
 };
 
 enum {
@@ -153,6 +155,8 @@
             PRIV_FLAGS_EXTERNAL_ONLY      = 0x00002000,
             // Display only this buffer on external
             PRIV_FLAGS_EXTERNAL_BLOCK     = 0x00004000,
+            // Display this buffer on external as close caption
+            PRIV_FLAGS_EXTERNAL_CC        = 0x00008000,
         };
 
         // file-descriptors