From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher James Halse Rogers Subject: Re: [PATCH] drm/i915/pch: Fix integer math bugs in panel fitting Date: Wed, 20 Jul 2011 17:15:05 +1000 Message-ID: <1311146112.13705.1.camel@Ed.fritz.box> References: <1310589152-31945-1-git-send-email-ajax@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0390147853==" Return-path: Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by gabe.freedesktop.org (Postfix) with ESMTP id 64EE49EF18 for ; Wed, 20 Jul 2011 00:15:15 -0700 (PDT) Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QjQzy-000437-04 for ; Wed, 20 Jul 2011 07:15:14 +0000 Received: from ppp105-211.static.internode.on.net ([150.101.105.211] helo=[192.168.178.31]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QjQzx-0007Zy-56 for intel-gfx@lists.freedesktop.org; Wed, 20 Jul 2011 07:15:13 +0000 In-Reply-To: <1310589152-31945-1-git-send-email-ajax@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============0390147853== Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-nsm+ycnfGUaMy2ZpOuSZ" --=-nsm+ycnfGUaMy2ZpOuSZ Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2011-07-13 at 16:32 -0400, Adam Jackson wrote: > Consider a 1600x900 panel, upscaling a 1360x768 mode, full-aspect. The > old math would give you: >=20 > scaled_width =3D 1600 * 768; /* 1228800 */ > scaled_height =3D 1360 * 900; /* 1224000 */ > if (scaled_width > scaled_height) { /* pillarbox, and true */ > width =3D 1224000 / 768; /* int(1593.75) =3D 1593 */ > x =3D (1600 - 1593 + 1) / 2; /* 4 */ > y =3D 0; > height =3D 768; > } /* ... */ >=20 > This is broken. The total width of scanout would then be 1593 + 4 + 4, > or 1601, which is wider than the panel itself. The hardware very > dutifully implements this, and you end up with a black 45=C2=B0 diagonal = from > the top-left corner to the bottom edge of the screen. It's a cool > effect and all, but not what you wanted. Similar things happen for the > letterbox case. >=20 > The problem is that you have an integer number of pixels, which means > it's usually impossible to upscale equally on both axes. 1360/768 is > 1.7708, 1600/900 is 1.7777. Since we're constrained on the one axis, > the other one wants to come out as an even number of pixels (the panel > is almost certainly even on both axes, and the x/y offsets will be > applied on both sides). In the math above, if 'width' comes out even, > rounding down is correct; if it's odd, you'd rather round up. So just > increment width/height in those cases. >=20 > Tested on a Lenovo T500 (Ironlake). >=20 > Signed-off-by: Adam Jackson > --- > drivers/gpu/drm/i915/intel_panel.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) >=20 > diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/in= tel_panel.c > index a06ff07..05f500c 100644 > --- a/drivers/gpu/drm/i915/intel_panel.c > +++ b/drivers/gpu/drm/i915/intel_panel.c > @@ -83,11 +83,15 @@ intel_pch_panel_fitting(struct drm_device *dev, > u32 scaled_height =3D mode->hdisplay * adjusted_mode->vdisplay; > if (scaled_width > scaled_height) { /* pillar */ > width =3D scaled_height / mode->vdisplay; > + if (width & 1) > + width++; > x =3D (adjusted_mode->hdisplay - width + 1) / 2; > y =3D 0; > height =3D adjusted_mode->vdisplay; > } else if (scaled_width < scaled_height) { /* letter */ > height =3D scaled_width / mode->hdisplay; > + if (height & 1) > + height++; > y =3D (adjusted_mode->vdisplay - height + 1) / 2; > x =3D 0; > width =3D adjusted_mode->hdisplay; We've seen this in Ubuntu in the form of https://bugs.launchpad.net/ubuntu/+source/linux/+bug/753994 so we can add a Tested-By: Daniel Manrique --=-nsm+ycnfGUaMy2ZpOuSZ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABCAAGBQJOJoB5AAoJEBiz9Q/lkjwYRYQP+wfxBJlizkBKHWYGtSl4iKjv 3lbNcMM8442tjQO7THiHAW519fpie3HQFRkFz/lSjqtPknMSDdEWuR6QrIjz9Uq2 WMIpvl0tgiFyE406nNbfcb1iJyHis4LOP2dIUEo1QxHE+Id+6rIlHTI2ekDvyz44 zxpKhJRwtXrjR24PYE5WqYnliXeWFoTta61LjbDyF0fWtHV0td+SUapR75Znfk2O N69cuofcyMD1mcjlLTcuOHwv7rtbLMU5X1+stXeFAWB7fk8usGJ603RJxxgVYDlg m41h9Tuz/aymAWi3o2xmiht1cnJsw53+AQUnqq2O6Upkgb/iIJFxJVTnRLLKoOSM 145Fup7SVvGYVsMov4Ky8FoSBBOEJ0uejT7Y+bbqP5u9XwACVjSyOtxo2afcQGFk +TpnkLJThJDCpSek4/IbeytGpYg/L0Qaj/c/QGxbI/bKNrGf9i3jxA9QXF5UW45v dm71J9yj8vgG++EsoUqRwkt2qUXU/Mln2LKS5Gw77rNu91kpRElX3Un4nEmWSm3X 9jcDEEi7W39oO0TDh8hvtrEqNJsmbvLLEhDlxjap9dDjZnk8drA2IGxEo5wIA/YH FCD2Q8h3BdwRHBQBEZdeB1gLWSI6xtt+HRjovAEOIaUPuAAP3/QNH5NE+zcX7ZPM 9ZF9TJrM9jRVoJHuDuLs =O/BU -----END PGP SIGNATURE----- --=-nsm+ycnfGUaMy2ZpOuSZ-- --===============0390147853== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============0390147853==--