diff mbox

[RFC] drm/i915: Make data/link N value power of two

Message ID 1366640630-3834-1-git-send-email-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjälä April 22, 2013, 2:23 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

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=49402
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
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.

 drivers/gpu/drm/i915/intel_display.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

Comments

Chris Wilson April 22, 2013, 4:19 p.m. UTC | #1
On Mon, Apr 22, 2013 at 05:23:50PM +0300, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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=49402
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

It should work, but I'd be impressed if someone could dig up a rationale
as to what is going wrong...
-Chris
Chris Wilson April 22, 2013, 4:20 p.m. UTC | #2
On Mon, Apr 22, 2013 at 05:23:50PM +0300, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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=49402
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Daniel Vetter April 22, 2013, 5:09 p.m. UTC | #3
On Mon, Apr 22, 2013 at 05:23:50PM +0300, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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=49402
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

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 = 24 -1 and
the magic 0xffffff = 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 >= 1 << 23)
> +		*ret_n = 1 << 23;
> +	else
> +		*ret_n = roundup_pow_of_two(n);
> +	*ret_m = 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 = 64;
> -	m_n->gmch_m = bits_per_pixel * pixel_clock;
> -	m_n->gmch_n = link_clock * nlanes * 8;
> -	intel_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n);
> -	m_n->link_m = pixel_clock;
> -	m_n->link_n = 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
Jesse Barnes April 23, 2013, 8:07 p.m. UTC | #4
On Mon, 22 Apr 2013 17:23:50 +0300
ville.syrjala@linux.intel.com wrote:

> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> 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=49402
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> 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.
> 
>  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 >= 1 << 23)
> +		*ret_n = 1 << 23;
> +	else
> +		*ret_n = roundup_pow_of_two(n);
> +	*ret_m = 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 = 64;
> -	m_n->gmch_m = bits_per_pixel * pixel_clock;
> -	m_n->gmch_n = link_clock * nlanes * 8;
> -	intel_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n);
> -	m_n->link_m = pixel_clock;
> -	m_n->link_n = 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)

You can add my Tested-by: to this one, it seems to fix
https://bugs.freedesktop.org/show_bug.cgi?id=59810 as well.

Art, is this something we've just missed and should have been doing all
along?

Thanks,
diff mbox

Patch

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 >= 1 << 23)
+		*ret_n = 1 << 23;
+	else
+		*ret_n = roundup_pow_of_two(n);
+	*ret_m = 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 = 64;
-	m_n->gmch_m = bits_per_pixel * pixel_clock;
-	m_n->gmch_n = link_clock * nlanes * 8;
-	intel_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n);
-	m_n->link_m = pixel_clock;
-	m_n->link_n = 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)