From 4319270881e8e9a0915aec140c1d8b5f6c27c876 Mon Sep 17 00:00:00 2001
From: Steve Fischer <steven.fischer@motorola.com>
Date: Thu, 2 Jul 2009 09:29:12 -0500
Subject: [PATCH] Proper Scaling Fix

---
 drivers/video/omap2/dss/manager.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/video/omap2/dss/manager.c b/drivers/video/omap2/dss/manager.c
index 0be370e..3ed9f3f 100644
--- a/drivers/video/omap2/dss/manager.c
+++ b/drivers/video/omap2/dss/manager.c
@@ -701,6 +701,8 @@ static int configure_overlay(enum omap_plane plane)
 	struct manager_cache_data *mc;
 	u16 outw, outh;
 	u16 x, y, w, h;
+	u32 dw = 0;
+	u32 dh = 0;
 	u32 paddr;
 	int r;
 
@@ -772,15 +774,25 @@ static int configure_overlay(enum omap_plane plane)
 			y = c->pos_y - mc->y;
 		}
 
-		if (mc->w < (x+w))
-			w = (x+w) - (mc->w);
+		if (mc->w < (x+outw)) {
+			dw = (x+outw) - (mc->w);
+			outw -= dw;
+		}
 
-		if (mc->h < (y+h))
-			h = (y+h) - (mc->h);
+		if (mc->h < (y+outh)) {
+			dh = (y+outh) - (mc->h);
+			outh -= dh;
+		}
 
 		if (!dispc_is_overlay_scaled(c)) {
-			outw = w;
-			outh = h;
+			w = outw;
+			h = outh;
+		} else {
+			if (dw)
+				w -= (u16) ((((dw << 16) / w) * outw) >> 16);
+
+			if (dh)
+				h -= (u16) ((((dh << 16) / h) * outh) >> 16);
 		}
 	}
 
-- 
1.5.4.3

