drm/radeon/kms: add PLL flag to prefer frequencies <= the target freq
authorAlex Deucher <alexdeucher@gmail.com>
Mon, 13 Jul 2009 15:08:18 +0000 (11:08 -0400)
committerDave Airlie <airlied@redhat.com>
Wed, 15 Jul 2009 07:13:22 +0000 (17:13 +1000)
This is needed when using fractional feedback dividers on some IGP
chips.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_mode.h

index 3efcf1a..bc312f3 100644 (file)
@@ -491,7 +491,11 @@ void radeon_compute_pll(struct radeon_pll *pll,
                                        tmp += (uint64_t)pll->reference_freq * 1000 * frac_feedback_div;
                                        current_freq = radeon_div(tmp, ref_div * post_div);
 
-                                       error = abs(current_freq - freq);
+                                       if (flags & RADEON_PLL_PREFER_CLOSEST_LOWER) {
+                                               error = freq - current_freq;
+                                               error = error < 0 ? 0xffffffff : error;
+                                       } else
+                                               error = abs(current_freq - freq);
                                        vco_diff = abs(vco - best_vco);
 
                                        if ((best_vco == 0 && error < best_error) ||
index 86f766e..38c1dd0 100644 (file)
@@ -124,6 +124,7 @@ struct radeon_tmds_pll {
 #define RADEON_PLL_PREFER_LOW_POST_DIV  (1 << 8)
 #define RADEON_PLL_PREFER_HIGH_POST_DIV (1 << 9)
 #define RADEON_PLL_USE_FRAC_FB_DIV      (1 << 10)
+#define RADEON_PLL_PREFER_CLOSEST_LOWER (1 << 11)
 
 struct radeon_pll {
        uint16_t reference_freq;