display: Add BufferMirrorMode support for External

- In Buffer mirror mode, the output on the external should be rotated
  based on the primary orientation.
- this is used for the side sync feature.
- buffermirrormode has higher precedence over external orientation
- Add binder interface to enable/disable buffermirror mode

Change-Id: Ibea0af9627d69b4d42453adc868b113d82613437
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp
index 7c2e643..a0f5faa 100644
--- a/libhwcomposer/hwc_fbupdate.cpp
+++ b/libhwcomposer/hwc_fbupdate.cpp
@@ -116,6 +116,10 @@
 
         ovutils::eTransform orient =
                     static_cast<ovutils::eTransform>(transform);
+        // use ext orientation if any
+        int extOrient = ctx->mExtOrientation;
+        if(ctx->mBufferMirrorMode)
+            extOrient = getMirrorModeOrientation(ctx);
 
         // Do not use getNonWormholeRegion() function to calculate the
         // sourceCrop during animation on external display and
@@ -125,7 +129,7 @@
             sourceCrop = layer->displayFrame;
             displayFrame = sourceCrop;
         } else if((!mDpy ||
-                   (mDpy && !ctx->mExtOrientation
+                   (mDpy && !extOrient
                    && !ctx->dpyAttr[mDpy].mDownScaleMode))
                    && (extOnlyLayerIndex == -1)) {
             if(!qdutils::MDPVersion::getInstance().is8x26()) {
@@ -134,13 +138,12 @@
             }
         }
         if(mDpy && !qdutils::MDPVersion::getInstance().is8x26()) {
-            if(ctx->mExtOrientation || ctx->dpyAttr[mDpy].mDownScaleMode) {
+            if(extOrient || ctx->dpyAttr[mDpy].mDownScaleMode) {
                 calcExtDisplayPosition(ctx, mDpy, sourceCrop, displayFrame);
                 // If there is a external orientation set, use that
-                if(ctx->mExtOrientation) {
-                    transform = ctx->mExtOrientation;
-                    orient =
-                        static_cast<ovutils::eTransform >(ctx->mExtOrientation);
+                if(extOrient) {
+                    transform = extOrient;
+                    orient = static_cast<ovutils::eTransform >(extOrient);
                 }
             }
             // Calculate the actionsafe dimensions for External(dpy = 1 or 2)
@@ -148,7 +151,7 @@
         }
         setMdpFlags(layer, mdpFlags, 0, transform);
         // For External use rotator if there is a rotation value set
-        if(mDpy && (ctx->mExtOrientation & HWC_TRANSFORM_ROT_90)) {
+        if(mDpy && (extOrient & HWC_TRANSFORM_ROT_90)) {
             mRot = ctx->mRotMgr->getNext();
             if(mRot == NULL) return -1;
             //Configure rotator for pre-rotation