summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/radeon.h1
-rw-r--r--src/radeon_crtc.c6
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) ||