hwc/overlay: Crop x, y, w and h should be even for MDSS Rotator.

MDSS driver requires Rotator crop x, y, w and h to be even for YUV
formats.

CRs-Fixed: 485216
Change-Id: I9a066970f8cedaed7ba18534bb99edd1bcf421dd
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 5df31b0..05bdfb9 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -754,12 +754,23 @@
 }
 
 inline int configRotator(Rotator *rot, const Whf& whf,
-        const hwc_rect_t& crop, const eMdpFlags& mdpFlags,
+        hwc_rect_t& crop, const eMdpFlags& mdpFlags,
         const eTransform& orient, const int& downscale) {
-    Dim rotCrop(crop.left, crop.top, (crop.right - crop.left),
-        (crop.bottom - crop.top));
+
     rot->setSource(whf);
-    rot->setCrop(rotCrop);
+
+    if (qdutils::MDPVersion::getInstance().getMDPVersion() >=
+        qdutils::MDSS_V5) {
+        uint32_t crop_w = (crop.right - crop.left);
+        uint32_t crop_h = (crop.bottom - crop.top);
+        ovutils::normalizeCrop((uint32_t&)crop.left, crop_w);
+        ovutils::normalizeCrop((uint32_t&)crop.top, crop_h);
+        crop.right = crop.left + crop_w;
+        crop.bottom = crop.top + crop_h;
+        Dim rotCrop(crop.left, crop.top, crop_w, crop_h);
+        rot->setCrop(rotCrop);
+    }
+
     rot->setFlags(mdpFlags);
     rot->setTransform(orient);
     rot->setDownscale(downscale);
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index db5880a..c65c09a 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -157,7 +157,7 @@
         int rotDownscale = 0, int transform = 0);
 
 int configRotator(overlay::Rotator *rot, const ovutils::Whf& whf,
-        const hwc_rect_t& crop, const ovutils::eMdpFlags& mdpFlags,
+        hwc_rect_t& crop, const ovutils::eMdpFlags& mdpFlags,
         const ovutils::eTransform& orient, const int& downscale);
 
 int configMdp(overlay::Overlay *ov, const ovutils::PipeArgs& parg,