From patchwork Wed Dec 7 15:06:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herton Ronaldo Krzesinski X-Patchwork-Id: 129981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 73D751007D5 for ; Thu, 8 Dec 2011 02:06:32 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1RYJ4a-0007mA-Nf; Wed, 07 Dec 2011 15:06:16 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1RYJ4Y-0007m5-Np for kernel-team@lists.ubuntu.com; Wed, 07 Dec 2011 15:06:14 +0000 Received: from 201.47.20.159.dynamic.adsl.gvt.net.br ([201.47.20.159] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1RYJ4Y-0006LA-3E for kernel-team@lists.ubuntu.com; Wed, 07 Dec 2011 15:06:14 +0000 From: "Herton R. Krzesinski" To: kernel-team@lists.ubuntu.com Subject: [PATCH] drm/i915/dp: Fix the math in intel_dp_link_required Date: Wed, 7 Dec 2011 13:06:07 -0200 Message-Id: <1323270367-6758-2-git-send-email-herton.krzesinski@canonical.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1323270367-6758-1-git-send-email-herton.krzesinski@canonical.com> References: <1323270367-6758-1-git-send-email-herton.krzesinski@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Adam Jackson The previous code was confused about units, which is pretty reasonable given that the units themselves are confusing. Signed-off-by: Adam Jackson Signed-off-by: Keith Packard BugLink: https://bugs.launchpad.net/bugs/899598 (backported from commit cd9dde44f47501394b9f0715b6a36a92aa74c0d0) Signed-off-by: Herton Ronaldo Krzesinski --- drivers/gpu/drm/i915/intel_dp.c | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 3ede21d..d4be591 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -174,16 +174,33 @@ intel_dp_link_clock(uint8_t link_bw) return 162000; } -/* I think this is a fiction */ +/* + * The units on the numbers in the next two are... bizarre. Examples will + * make it clearer; this one parallels an example in the eDP spec. + * + * intel_dp_max_data_rate for one lane of 2.7GHz evaluates as: + * + * 270000 * 1 * 8 / 10 == 216000 + * + * The actual data capacity of that configuration is 2.16Gbit/s, so the + * units are decakilobits. ->clock in a drm_display_mode is in kilohertz - + * or equivalently, kilopixels per second - so for 1680x1050R it'd be + * 119000. At 18bpp that's 2142000 kilobits per second. + * + * Thus the strange-looking division by 10 in intel_dp_link_required, to + * get the result in decakilobits instead of kilobits. + */ + static int intel_dp_link_required(struct drm_device *dev, struct intel_dp *intel_dp, int pixel_clock) { struct drm_i915_private *dev_priv = dev->dev_private; + int bpp = 24; if (is_edp(intel_dp)) - return (pixel_clock * dev_priv->edp.bpp + 7) / 8; - else - return pixel_clock * 3; + bpp = dev_priv->edp.bpp; + + return (pixel_clock * bpp + 9) / 10; } static int