aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-12-03 20:01:29 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2010-12-03 18:51:02 -0500
commit22ed1113a9adda6e193c329119a384362da01289 (patch)
treef9c8c2132c539f7fe3230c75aab11a8f927b4af6
parent47f1c6c9ffdec0c0e5a2c2709bd63c7380b325c4 (diff)
drm/i915: Death to the unnecessary 64bit divide
Use the hardware DDA to calculate the ratio with as much accuracy as is possible. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: stable@kernel.org
-rw-r--r--drivers/gpu/drm/i915/intel_display.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index e5badadbdcd2..fac118b2df7d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2714,27 +2714,19 @@ fdi_reduce_ratio(u32 *num, u32 *den)
2714 } 2714 }
2715} 2715}
2716 2716
2717#define DATA_N 0x800000
2718#define LINK_N 0x80000
2719
2720static void 2717static void
2721ironlake_compute_m_n(int bits_per_pixel, int nlanes, int pixel_clock, 2718ironlake_compute_m_n(int bits_per_pixel, int nlanes, int pixel_clock,
2722 int link_clock, struct fdi_m_n *m_n) 2719 int link_clock, struct fdi_m_n *m_n)
2723{ 2720{
2724 u64 temp;
2725
2726 m_n->tu = 64; /* default size */ 2721 m_n->tu = 64; /* default size */
2727 2722
2728 temp = (u64) DATA_N * pixel_clock; 2723 /* BUG_ON(pixel_clock > INT_MAX / 36); */
2729 temp = div_u64(temp, link_clock); 2724 m_n->gmch_m = bits_per_pixel * pixel_clock;
2730 m_n->gmch_m = div_u64(temp * bits_per_pixel, nlanes); 2725 m_n->gmch_n = link_clock * nlanes * 8;
2731 m_n->gmch_m >>= 3; /* convert to bytes_per_pixel */
2732 m_n->gmch_n = DATA_N;
2733 fdi_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n); 2726 fdi_reduce_ratio(&m_n->gmch_m, &m_n->gmch_n);
2734 2727
2735 temp = (u64) LINK_N * pixel_clock; 2728 m_n->link_m = pixel_clock;
2736 m_n->link_m = div_u64(temp, link_clock); 2729 m_n->link_n = link_clock;
2737 m_n->link_n = LINK_N;
2738 fdi_reduce_ratio(&m_n->link_m, &m_n->link_n); 2730 fdi_reduce_ratio(&m_n->link_m, &m_n->link_n);
2739} 2731}
2740 2732