diff options
-rw-r--r-- | drivers/video/tridentfb.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c index 138140bdb49..854e2e5af58 100644 --- a/drivers/video/tridentfb.c +++ b/drivers/video/tridentfb.c @@ -672,15 +672,16 @@ static void set_vclk(struct tridentfb_par *par, unsigned long freq) unsigned long fi, d, di; unsigned char best_m = 0, best_n = 0, best_k = 0; unsigned char hi, lo; + unsigned char shift = !is_oldclock(par->chip_id) ? 2 : 1; d = 20000; - for (k = 1; k >= 0; k--) - for (m = 0; m < 32; m++) { - n = 2 * (m + 2) - 8; + for (k = shift; k >= 0; k--) + for (m = 1; m < 32; m++) { + n = ((m + 2) << shift) - 8; for (n = (n < 0 ? 0 : n); n < 122; n++) { fi = ((14318l * (n + 8)) / (m + 2)) >> k; di = abs(fi - freq); - if (di <= d) { + if (di < d || (di == d && k == best_k)) { d = di; best_n = n; best_m = m; |