From: Daniel Vetter Subject: Re: [RFC][PATCH] drm/i915: Make data/link N value power of two Date: Mon, 22 Apr 2013 19:09:27 +0200 Message-ID: <20130422170926.GD6169@phenom.ffwll.local> References: <1366640630-3834-1-git-send-email-ville.syrjala@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) by gabe.freedesktop.org (Postfix) with ESMTP id 29230E5F57 for ; Mon, 22 Apr 2013 10:06:25 -0700 (PDT) Received: by mail-we0-f181.google.com with SMTP id m1so177138wea.26 for ; Mon, 22 Apr 2013 10:06:24 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1366640630-3834-1-git-send-email-ville.syrjala@linux.intel.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: ville.syrjala@linux.intel.com Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Mon, Apr 22, 2013 at 05:23:50PM +0300, ville.syrjala@linux.intel.com wro= te: > From: Ville Syrj=E4l=E4 > = > The BIOS uses power of two values for the data/link N value. > = > Follow suit to make the Zotac DP to dual-HDMI dongle work. > = > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=3D49402 > Signed-off-by: Ville Syrj=E4l=E4 Since it took me a while to fire up my brain and understand the magic values ... can we please have some #defines for the magic 23 =3D 24 -1 and the magic 0xffffff =3D 1 << (24) - 1 ? Also maybe call intel_reduce_ratio intel_reduce_m_n_ratio or so while at it. > --- > Warning: I've only tested this with the Zotac dongle hooked to my 1080p > Samsumg telly. Whether or not it works with other displays is an open > question. It's pretty early for 3.10, so I think we can just stick this into -fixes and see what happens. -Daniel > = > drivers/gpu/drm/i915/intel_display.c | 23 +++++++++++++++++------ > 1 file changed, 17 insertions(+), 6 deletions(-) > = > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/= intel_display.c > index 74156e2..fea9c99 100644 > --- a/drivers/gpu/drm/i915/intel_display.c > +++ b/drivers/gpu/drm/i915/intel_display.c > @@ -4151,18 +4151,29 @@ intel_reduce_ratio(uint32_t *num, uint32_t *den) > } > } > = > +static void compute_m_n(int m, int n, uint32_t *ret_m, uint32_t *ret_n) > +{ > + if (n >=3D 1 << 23) > + *ret_n =3D 1 << 23; > + else > + *ret_n =3D roundup_pow_of_two(n); > + *ret_m =3D div_u64((uint64_t) m * *ret_n, n); > + intel_reduce_ratio(ret_m, ret_n); > +} > + > void > intel_link_compute_m_n(int bits_per_pixel, int nlanes, > int pixel_clock, int link_clock, > struct intel_link_m_n *m_n) > { > m_n->tu =3D 64; > - m_n->gmch_m =3D bits_per_pixel * pixel_clock; > - m_n->gmch_n =3D link_clock * nlanes * 8; > - intel_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n); > - m_n->link_m =3D pixel_clock; > - m_n->link_n =3D link_clock; > - intel_reduce_ratio(&m_n->link_m, &m_n->link_n); > + > + compute_m_n(bits_per_pixel * pixel_clock, > + link_clock * nlanes * 8, > + &m_n->gmch_m, &m_n->gmch_n); > + > + compute_m_n(pixel_clock, link_clock, > + &m_n->link_m, &m_n->link_n); > } > = > static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv) > -- = > 1.8.1.5 > = > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch