diff options
author | Alex Deucher <alexdeucher@gmail.com> | 2009-06-11 12:31:53 -0400 |
---|---|---|
committer | Alex Deucher <alexdeucher@gmail.com> | 2009-06-11 12:31:53 -0400 |
commit | 55fbdbae83d1563b472f49d0436c9298e390be66 (patch) | |
tree | 6090e89be91d733bb74ba0b471b902b11ad9735f | |
parent | 43374c7420e378918bec062f4cbd581f16adb6f0 (diff) |
Add PLL flag to prefer frequencies <= the target freq
This appears to be needed when using fractional feedback
dividers. Based on a patch from Tom Hirst. See fdo
bug 22229 for more details.
-rw-r--r-- | src/radeon.h | 1 | ||||
-rw-r--r-- | src/radeon_crtc.c | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/radeon.h b/src/radeon.h index d4604010..2145de54 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -262,6 +262,7 @@ typedef struct { #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) typedef struct { uint16_t reference_freq; diff --git a/src/radeon_crtc.c b/src/radeon_crtc.c index c78ac43b..3899064f 100644 --- a/src/radeon_crtc.c +++ b/src/radeon_crtc.c @@ -230,7 +230,11 @@ RADEONComputePLL(RADEONPLLPtr pll, tmp += (CARD64)pll->reference_freq * 1000 * frac_feedback_div; current_freq = RADEONDiv(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) || |