hwc: Add support for secure RGB layer

1. Detect and account the number of secure RGB layers present.
2. Mark secure RGB layers for MDP comp in cache based stratergy.
3. If full MDP comp and partial MDP comp fails, Mark secure RGB
   layers for MDP composition.
4. In partial MDP comp reject load based composition, if secure
   layer is present to avoid GPU composition.
5. Disable idlefallback feature if secure RGB layer is present
   to avoid GPU composition.

Change-Id: Idb4c4f09b081ec20240a2602aa3f20332fa49ad6
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 944f152..f6e5dd0 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -841,6 +841,7 @@
     ctx->listStats[dpy].yuv4k2kCount = 0;
     ctx->dpyAttr[dpy].mActionSafePresent = isActionSafePresent(ctx, dpy);
     ctx->listStats[dpy].renderBufIndexforABC = -1;
+    ctx->listStats[dpy].secureRGBCount = 0;
 
     resetROI(ctx, dpy);
 
@@ -868,6 +869,12 @@
 
         if (isSecureBuffer(hnd)) {
             ctx->listStats[dpy].isSecurePresent = true;
+            if(not isYuvBuffer(hnd)) {
+                // cache secureRGB layer parameters like we cache for YUV layers
+                int& secureRGBCount = ctx->listStats[dpy].secureRGBCount;
+                ctx->listStats[dpy].secureRGBIndices[secureRGBCount] = (int)i;
+                secureRGBCount++;
+            }
         }
 
         if (isSkipLayer(&list->hwLayers[i])) {
@@ -1477,22 +1484,20 @@
                 ovutils::OV_MDP_BLEND_FG_PREMULT);
     }
 
-    if(isYuvBuffer(hnd)) {
-        if(isSecureBuffer(hnd)) {
-            ovutils::setMdpFlags(mdpFlags,
-                    ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
-        }
-        if(metadata && (metadata->operation & PP_PARAM_INTERLACED) &&
-                metadata->interlaced) {
-            ovutils::setMdpFlags(mdpFlags,
-                    ovutils::OV_MDP_DEINTERLACE);
-        }
+    if(metadata && (metadata->operation & PP_PARAM_INTERLACED) &&
+            metadata->interlaced) {
+        ovutils::setMdpFlags(mdpFlags,
+                ovutils::OV_MDP_DEINTERLACE);
+    }
+
+    // Mark MDP flags with SECURE_OVERLAY_SESSION for driver
+    if(isSecureBuffer(hnd)) {
+        ovutils::setMdpFlags(mdpFlags,
+                ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
     }
 
     if(isSecureDisplayBuffer(hnd)) {
-        // Secure display needs both SECURE_OVERLAY and SECURE_DISPLAY_OV
-        ovutils::setMdpFlags(mdpFlags,
-                             ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
+        // Mark MDP flags with SECURE_DISPLAY_OVERLAY_SESSION for driver
         ovutils::setMdpFlags(mdpFlags,
                              ovutils::OV_MDP_SECURE_DISPLAY_OVERLAY_SESSION);
     }