From patchwork Wed Dec 7 15:06:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: drm/i915/dp: Fix the math in intel_dp_link_required Date: Wed, 07 Dec 2011 05:06:07 -0000 From: Herton Ronaldo Krzesinski X-Patchwork-Id: 129981 Message-Id: <1323270367-6758-2-git-send-email-herton.krzesinski@canonical.com> To: kernel-team@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