hwc: Add assertive display support.

Add assertive display support to hwc. This feature takes effect when
node /sys/class/graphics/fb*/ad is present. This signifies that that LM0
is being used with fb* for writeback.

When a video playback begins we write "1" to this node to indicate to
post processing that a writeback will happen. Likewise a "0" is written
to this node when playback stops.

The original contents are worked upon and the modified output is fed
via writeback to either rotator or mdp as appropriate.

The feature doesnt trigger when either:
1) Buffer size exceeds 2048
2) External display is connected
3) Multiple yuv streams are present

When this mode is active, MDP comp is applied only to yuv layer.

Change-Id: If5520f9dc849de3189c9f9ed4e9072c8f8f760e1
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 462cc6d..4960505 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -23,6 +23,7 @@
 #include "qdMetaData.h"
 #include "mdp_version.h"
 #include "hwc_fbupdate.h"
+#include "hwc_ad.h"
 #include <overlayRotator.h>
 
 using namespace overlay;
@@ -453,6 +454,10 @@
                    return false;
     }
 
+    if(ctx->mAD->isDoable()) {
+        return false;
+    }
+
     //If all above hard conditions are met we can do full or partial MDP comp.
     bool ret = false;
     if(fullMDPComp(ctx, list)) {
@@ -955,6 +960,14 @@
 
         int fd = hnd->fd;
         uint32_t offset = hnd->offset;
+
+        if(ctx->mAD->isModeOn()) {
+            if(ctx->mAD->draw(ctx, fd, offset)) {
+                fd = ctx->mAD->getDstFd(ctx);
+                offset = ctx->mAD->getDstOffset(ctx);
+            }
+        }
+
         Rotator *rot = mCurrentFrame.mdpToLayer[mdpIndex].rot;
         if(rot) {
             if(!rot->queueBuffer(fd, offset))
@@ -1161,6 +1174,13 @@
         int fd = hnd->fd;
         int offset = hnd->offset;
 
+        if(ctx->mAD->isModeOn()) {
+            if(ctx->mAD->draw(ctx, fd, offset)) {
+                fd = ctx->mAD->getDstFd(ctx);
+                offset = ctx->mAD->getDstOffset(ctx);
+            }
+        }
+
         if(rot) {
             rot->queueBuffer(fd, offset);
             fd = rot->getDstMemId();