diff options
author | Christian König <christian.koenig@amd.com> | 2014-04-16 05:54:21 -0400 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2014-04-17 08:14:18 -0400 |
commit | f8a2645ecede4eaf90b3d785f2805c8ecb76d43e (patch) | |
tree | 7268ea388aa053239e8876e9ae08c71871faf432 /drivers/gpu | |
parent | 74073c9dd29905645feb6dee03c144657a9844cd (diff) |
drm/radeon: improve PLL params if we don't match exactly v2
Otherwise we might be quite off on older chipsets.
v2: keep ref_div minimum
Signed-off-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_display.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 2f42912031ac..063d4255137f 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
@@ -865,7 +865,7 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
865 | unsigned post_div_min, post_div_max, post_div; | 865 | unsigned post_div_min, post_div_max, post_div; |
866 | unsigned ref_div_min, ref_div_max, ref_div; | 866 | unsigned ref_div_min, ref_div_max, ref_div; |
867 | unsigned post_div_best, diff_best; | 867 | unsigned post_div_best, diff_best; |
868 | unsigned nom, den, tmp; | 868 | unsigned nom, den; |
869 | 869 | ||
870 | /* determine allowed feedback divider range */ | 870 | /* determine allowed feedback divider range */ |
871 | fb_div_min = pll->min_feedback_div; | 871 | fb_div_min = pll->min_feedback_div; |
@@ -941,22 +941,23 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll, | |||
941 | ref_div_max = min(210 / post_div, ref_div_max); | 941 | ref_div_max = min(210 / post_div, ref_div_max); |
942 | 942 | ||
943 | /* get matching reference and feedback divider */ | 943 | /* get matching reference and feedback divider */ |
944 | ref_div = max(den / post_div, 1u); | 944 | ref_div = max(DIV_ROUND_CLOSEST(den, post_div), 1u); |
945 | fb_div = nom; | 945 | fb_div = DIV_ROUND_CLOSEST(nom * ref_div * post_div, den); |
946 | 946 | ||
947 | /* we're almost done, but reference and feedback | 947 | /* we're almost done, but reference and feedback |
948 | divider might be to large now */ | 948 | divider might be to large now */ |
949 | 949 | ||
950 | tmp = ref_div; | 950 | nom = fb_div; |
951 | den = ref_div; | ||
951 | 952 | ||
952 | if (fb_div > fb_div_max) { | 953 | if (fb_div > fb_div_max) { |
953 | ref_div = ref_div * fb_div_max / fb_div; | 954 | ref_div = DIV_ROUND_CLOSEST(den * fb_div_max, nom); |
954 | fb_div = fb_div_max; | 955 | fb_div = fb_div_max; |
955 | } | 956 | } |
956 | 957 | ||
957 | if (ref_div > ref_div_max) { | 958 | if (ref_div > ref_div_max) { |
958 | ref_div = ref_div_max; | 959 | ref_div = ref_div_max; |
959 | fb_div = nom * ref_div_max / tmp; | 960 | fb_div = DIV_ROUND_CLOSEST(nom * ref_div_max, den); |
960 | } | 961 | } |
961 | 962 | ||
962 | /* reduce the numbers to a simpler ratio once more */ | 963 | /* reduce the numbers to a simpler ratio once more */ |