diff options
author | Krzysztof Helt <krzysztof.h1@wp.pl> | 2008-10-16 01:03:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-16 14:21:43 -0400 |
commit | 7528f543889fd460964b42881296b2e84457684e (patch) | |
tree | 512b7c766bacbfee1593673debf865cadaf60893 /drivers/video | |
parent | 786e463e7fcd4ad26fede828f22033584563584a (diff) |
cirrusfb: simplify clock calculation
Simplify clock calculation.
Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/cirrusfb.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c index 09f42145a5db..dfd12a2dfe72 100644 --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c | |||
@@ -3075,38 +3075,36 @@ static void bestclock(long freq, long *best, long *nom, | |||
3075 | f = freq * 10; | 3075 | f = freq * 10; |
3076 | 3076 | ||
3077 | for (n = 32; n < 128; n++) { | 3077 | for (n = 32; n < 128; n++) { |
3078 | int s = 0; | ||
3079 | |||
3078 | d = (143181 * n) / f; | 3080 | d = (143181 * n) / f; |
3079 | if ((d >= 7) && (d <= 63)) { | 3081 | if ((d >= 7) && (d <= 63)) { |
3080 | if (d > 31) | 3082 | int temp = d; |
3081 | d = (d / 2) * 2; | 3083 | |
3082 | h = (14318 * n) / d; | 3084 | if (temp > 31) { |
3085 | s = 1; | ||
3086 | temp >>= 1; | ||
3087 | } | ||
3088 | h = ((14318 * n) / temp) >> s; | ||
3083 | if (abs(h - freq) < abs(*best - freq)) { | 3089 | if (abs(h - freq) < abs(*best - freq)) { |
3084 | *best = h; | 3090 | *best = h; |
3085 | *nom = n; | 3091 | *nom = n; |
3086 | if (d < 32) { | 3092 | *den = temp; |
3087 | *den = d; | 3093 | *div = s; |
3088 | *div = 0; | ||
3089 | } else { | ||
3090 | *den = d / 2; | ||
3091 | *div = 1; | ||
3092 | } | ||
3093 | } | 3094 | } |
3094 | } | 3095 | } |
3095 | d = DIV_ROUND_UP(143181 * n, f); | 3096 | d++; |
3096 | if ((d >= 7) && (d <= 63)) { | 3097 | if ((d >= 7) && (d <= 63)) { |
3097 | if (d > 31) | 3098 | if (d > 31) { |
3098 | d = (d / 2) * 2; | 3099 | s = 1; |
3099 | h = (14318 * n) / d; | 3100 | d >>= 1; |
3101 | } | ||
3102 | h = ((14318 * n) / d) >> s; | ||
3100 | if (abs(h - freq) < abs(*best - freq)) { | 3103 | if (abs(h - freq) < abs(*best - freq)) { |
3101 | *best = h; | 3104 | *best = h; |
3102 | *nom = n; | 3105 | *nom = n; |
3103 | if (d < 32) { | 3106 | *den = d; |
3104 | *den = d; | 3107 | *div = s; |
3105 | *div = 0; | ||
3106 | } else { | ||
3107 | *den = d / 2; | ||
3108 | *div = 1; | ||
3109 | } | ||
3110 | } | 3108 | } |
3111 | } | 3109 | } |
3112 | } | 3110 | } |