overlay: Add tolerance to downscale factor

In certain corner cases for 1080p panels, round doesn't get us
the right downscale factor resulting in MDP attempting to go into
blt mode. Add a tolerance for failure.

Bug: 9322550
Change-Id: I2be4715955d9e248fc63e408dc4a2cdf493152f6
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/liboverlay/overlayUtils.cpp b/liboverlay/overlayUtils.cpp
index 6906ef8..f0b61b3 100644
--- a/liboverlay/overlayUtils.cpp
+++ b/liboverlay/overlayUtils.cpp
@@ -183,6 +183,9 @@
 int getDownscaleFactor(const int& src_w, const int& src_h,
         const int& dst_w, const int& dst_h) {
     int dscale_factor = utils::ROT_DS_NONE;
+    // The tolerance is an empirical grey area that needs to be adjusted
+    // manually so that we always err on the side of caution
+    float fDscaleTolerance = 0.05;
     // We need this check to engage the rotator whenever possible to assist MDP
     // in performing video downscale.
     // This saves bandwidth and avoids causing the driver to make too many panel
@@ -190,14 +193,15 @@
     // Use-case: Video playback [with downscaling and rotation].
     if (dst_w && dst_h)
     {
-        float fDscale =  (float)(src_w * src_h) / (float)(dst_w * dst_h);
+        float fDscale =  sqrtf((float)(src_w * src_h) / (float)(dst_w * dst_h)) +
+                         fDscaleTolerance;
 
         // On our MTP 1080p playback case downscale after sqrt is coming to 1.87
         // we were rounding to 1. So entirely MDP has to do the downscaling.
         // BW requirement and clock requirement is high across MDP4 targets.
         // It is unable to downscale 1080p video to panel resolution on 8960.
         // round(x) will round it to nearest integer and avoids above issue.
-        uint32_t dscale = round(sqrtf(fDscale));
+        uint32_t dscale = round(fDscale);
 
         if(dscale < 2) {
             // Down-scale to > 50% of orig.