Merge "display: Fix merge issue in jb_mr1"
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index 20f7973..9af52c9 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -196,8 +196,8 @@
     if(usage & GRALLOC_USAGE_PRIVATE_MM_HEAP)
         ionFlags |= ION_HEAP(ION_CP_MM_HEAP_ID);
 
-    if(usage & GRALLOC_USAGE_PRIVATE_CAMERA_HEAP)
-        ionFlags |= ION_HEAP(ION_CAMERA_HEAP_ID);
+    if(usage & GRALLOC_USAGE_PRIVATE_ADSP_HEAP)
+        ionFlags |= ION_HEAP(ION_ADSP_HEAP_ID);
 
     if(usage & GRALLOC_USAGE_PROTECTED && !noncontig)
         ionFlags |= ION_SECURE;
diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h
index 719a941..c382a90 100644
--- a/libgralloc/gralloc_priv.h
+++ b/libgralloc/gralloc_priv.h
@@ -47,8 +47,8 @@
     GRALLOC_USAGE_PRIVATE_IOMMU_HEAP      =       GRALLOC_USAGE_PRIVATE_2,
     /* MM heap is a carveout heap for video, can be secured*/
     GRALLOC_USAGE_PRIVATE_MM_HEAP         =       GRALLOC_USAGE_PRIVATE_3,
-    /* CAMERA heap is a carveout heap for camera, is not secured*/
-    GRALLOC_USAGE_PRIVATE_CAMERA_HEAP     =       0x01000000,
+    /* ADSP heap is a carveout heap, is not secured*/
+    GRALLOC_USAGE_PRIVATE_ADSP_HEAP       =       0x01000000,
 
     /* Set this for allocating uncached memory (using O_DSYNC)
      * cannot be used with noncontiguous heaps */
@@ -84,7 +84,7 @@
                              GRALLOC_USAGE_PRIVATE_SYSTEM_HEAP    |\
                              GRALLOC_USAGE_PRIVATE_IOMMU_HEAP     |\
                              GRALLOC_USAGE_PRIVATE_MM_HEAP        |\
-                             GRALLOC_USAGE_PRIVATE_CAMERA_HEAP)
+                             GRALLOC_USAGE_PRIVATE_ADSP_HEAP)
 
 #define INTERLACE_MASK 0x80
 #define S3D_FORMAT_MASK 0xFF000
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index 268630b..9c97aae 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -313,6 +313,7 @@
                 res = 0;
             }
             break;
+#endif
         case GRALLOC_MODULE_PERFORM_GET_STRIDE:
             {
                 int width   = va_arg(args, int);
@@ -321,7 +322,6 @@
                 *stride = AdrenoMemInfo::getInstance().getStride(width, format);
                 res = 0;
             } break;
-#endif
         default:
             break;
     }
diff --git a/libhwcomposer/hwc_qclient.cpp b/libhwcomposer/hwc_qclient.cpp
index c130208..edf579f 100644
--- a/libhwcomposer/hwc_qclient.cpp
+++ b/libhwcomposer/hwc_qclient.cpp
@@ -42,11 +42,7 @@
 QClient::QClient(hwc_context_t *ctx) : mHwcContext(ctx),
         mMPDeathNotifier(new MPDeathNotifier(ctx))
 {
-
     ALOGD_IF(QCLIENT_DEBUG, "QClient Constructor invoked");
-    //The only way to make this class in this process subscribe to media
-    //player's death.
-    IMediaDeathNotifier::getMediaPlayerService();
 }
 
 QClient::~QClient()
@@ -72,6 +68,10 @@
 }
 
 void QClient::securing(uint32_t startEnd) {
+    //The only way to make this class in this process subscribe to media
+    //player's death.
+    IMediaDeathNotifier::getMediaPlayerService();
+
     mHwcContext->mSecuring = startEnd;
     //We're done securing
     if(startEnd == IQService::END)
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 84da5c4..013833f 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -635,6 +635,9 @@
     Dim srcCrop(crop.left, crop.top,
             crop.right - crop.left,
             crop.bottom - crop.top);
+    //getMdpOrient will switch the flips if the source is 90 rotated.
+    //Clients in Android dont factor in 90 rotation while deciding the flip.
+    orient = static_cast<eTransform>(ovutils::getMdpOrient(orient));
     preRotateSource(orient, whf, srcCrop);
     crop.left = srcCrop.x;
     crop.top = srcCrop.y;
@@ -685,11 +688,13 @@
             return -1;
         whf.format = (*rot)->getDstFormat();
         updateSource(orient, whf, crop);
-        //For the mdp, since we are pre-rotating
-        transform = 0;
         rotFlags |= ovutils::ROT_PREROTATED;
     }
 
+    //For the mdp, since either we are pre-rotating or MDP does flips
+    orient = OVERLAY_TRANSFORM_0;
+    transform = 0;
+
     PipeArgs parg(mdpFlags, whf, z, isFg, static_cast<eRotFlags>(rotFlags));
     if(configMdp(ctx->mOverlay, parg, orient, crop, dst, dest) < 0) {
         ALOGE("%s: commit failed for low res panel", __FUNCTION__);
@@ -731,8 +736,6 @@
             return -1;
         whf.format = (*rot)->getDstFormat();
         updateSource(orient, whf, crop);
-        //For the mdp, since we are pre-rotating
-        transform = 0;
         rotFlags |= ROT_PREROTATED;
     }
 
@@ -758,7 +761,7 @@
     //When buffer is flipped, contents of mixer config also needs to swapped.
     //Not needed if the layer is confined to one half of the screen.
     //If rotator has been used then it has also done the flips, so ignore them.
-    if(layer->transform & HWC_TRANSFORM_FLIP_V && lDest != OV_INVALID
+    if((orient & OVERLAY_TRANSFORM_FLIP_V) && lDest != OV_INVALID
             && rDest != OV_INVALID && rot == NULL) {
         hwc_rect_t new_cropR;
         new_cropR.left = tmp_cropL.left;
@@ -776,6 +779,10 @@
 
     }
 
+    //For the mdp, since either we are pre-rotating or MDP does flips
+    orient = OVERLAY_TRANSFORM_0;
+    transform = 0;
+
     //configure left mixer
     if(lDest != OV_INVALID) {
         PipeArgs pargL(mdpFlagsL, whf, z, isFg,
diff --git a/liboverlay/overlayMdp.h b/liboverlay/overlayMdp.h
index 7d3bbee..08d744f 100644
--- a/liboverlay/overlayMdp.h
+++ b/liboverlay/overlayMdp.h
@@ -296,10 +296,8 @@
 
 inline void MdpCtrl::setRotationFlags() {
     const int u = getUserData();
-    if (u == MDP_ROT_90 || u == MDP_ROT_270)
+    if (u & MDP_ROT_90)
         mOVInfo.flags |= MDP_SOURCE_ROTATED_90;
-    else
-        mOVInfo.flags &= ~MDP_SOURCE_ROTATED_90;
 }
 
 ///////    MdpCtrl3D //////
diff --git a/liboverlay/overlayUtils.cpp b/liboverlay/overlayUtils.cpp
index 2eed1e9..8cc9cc0 100644
--- a/liboverlay/overlayUtils.cpp
+++ b/liboverlay/overlayUtils.cpp
@@ -212,7 +212,10 @@
     return x - ( y + z );
 }
 
-void preRotateSource(eTransform& tr, Whf& whf, Dim& srcCrop) {
+//Expects transform to be adjusted for clients of Android.
+//i.e flips switched if 90 component present.
+//See getMdpOrient()
+void preRotateSource(const eTransform& tr, Whf& whf, Dim& srcCrop) {
     if(tr & OVERLAY_TRANSFORM_FLIP_H) {
         srcCrop.x = compute(whf.w, srcCrop.x, srcCrop.w);
     }
@@ -228,7 +231,6 @@
         swap(whf.w, whf.h);
         swap(srcCrop.w, srcCrop.h);
     }
-    tr = OVERLAY_TRANSFORM_0;
 }
 
 bool is3DTV() {
diff --git a/liboverlay/overlayUtils.h b/liboverlay/overlayUtils.h
index 5eb0e1e..3eabc1d 100644
--- a/liboverlay/overlayUtils.h
+++ b/liboverlay/overlayUtils.h
@@ -688,7 +688,7 @@
         value--;
 }
 
-void preRotateSource(eTransform& tr, Whf& whf, Dim& srcCrop);
+void preRotateSource(const eTransform& tr, Whf& whf, Dim& srcCrop);
 void getDump(char *buf, size_t len, const char *prefix, const mdp_overlay& ov);
 void getDump(char *buf, size_t len, const char *prefix, const msmfb_img& ov);
 void getDump(char *buf, size_t len, const char *prefix, const mdp_rect& ov);