diff options
Diffstat (limited to 'drivers/video/intelfb')
-rw-r--r-- | drivers/video/intelfb/intelfbhw.c | 73 |
1 files changed, 34 insertions, 39 deletions
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c index 82a2b9048df9..5a621df5bf02 100644 --- a/drivers/video/intelfb/intelfbhw.c +++ b/drivers/video/intelfb/intelfbhw.c | |||
@@ -600,23 +600,19 @@ static int calc_vclock3(int index, int m, int n, int p) | |||
600 | 600 | ||
601 | static int calc_vclock(int index, int m1, int m2, int n, int p1, int p2, int lvds) | 601 | static int calc_vclock(int index, int m1, int m2, int n, int p1, int p2, int lvds) |
602 | { | 602 | { |
603 | int p2_val; | 603 | struct pll_min_max *pll = &plls[index]; |
604 | switch(index) | 604 | u32 m, vco, p; |
605 | { | 605 | |
606 | case PLLS_I9xx: | 606 | m = (5 * (m1 + 2)) + (m2 + 2); |
607 | if (p1 == 0) | 607 | n += 2; |
608 | return 0; | 608 | vco = pll->ref_clk * m / n; |
609 | if (lvds) | 609 | |
610 | p2_val = p2 ? 7 : 14; | 610 | if (index == PLLS_I8xx) { |
611 | else | 611 | p = ((p1 + 2) * (1 << (p2 + 1))); |
612 | p2_val = p2 ? 5 : 10; | 612 | } else { |
613 | return ((plls[index].ref_clk * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / | 613 | p = ((p1) * (p2 ? 5 : 10)); |
614 | ((p1)) * (p2_val))); | ||
615 | case PLLS_I8xx: | ||
616 | default: | ||
617 | return ((plls[index].ref_clk * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / | ||
618 | ((p1+2) * (1 << (p2 + 1))))); | ||
619 | } | 614 | } |
615 | return vco / p; | ||
620 | } | 616 | } |
621 | 617 | ||
622 | void | 618 | void |
@@ -852,9 +848,11 @@ splitm(int index, unsigned int m, unsigned int *retm1, unsigned int *retm2) | |||
852 | { | 848 | { |
853 | int m1, m2; | 849 | int m1, m2; |
854 | int testm; | 850 | int testm; |
851 | struct pll_min_max *pll = &plls[index]; | ||
852 | |||
855 | /* no point optimising too much - brute force m */ | 853 | /* no point optimising too much - brute force m */ |
856 | for (m1 = plls[index].min_m1; m1 < plls[index].max_m1+1; m1++) { | 854 | for (m1 = pll->min_m1; m1 < pll->max_m1 + 1; m1++) { |
857 | for (m2 = plls[index].min_m2; m2 < plls[index].max_m2+1; m2++) { | 855 | for (m2 = pll->min_m2; m2 < pll->max_m2 + 1; m2++) { |
858 | testm = (5 * (m1 + 2)) + (m2 + 2); | 856 | testm = (5 * (m1 + 2)) + (m2 + 2); |
859 | if (testm == m) { | 857 | if (testm == m) { |
860 | *retm1 = (unsigned int)m1; | 858 | *retm1 = (unsigned int)m1; |
@@ -871,6 +869,7 @@ static int | |||
871 | splitp(int index, unsigned int p, unsigned int *retp1, unsigned int *retp2) | 869 | splitp(int index, unsigned int p, unsigned int *retp1, unsigned int *retp2) |
872 | { | 870 | { |
873 | int p1, p2; | 871 | int p1, p2; |
872 | struct pll_min_max *pll = &plls[index]; | ||
874 | 873 | ||
875 | if (index == PLLS_I9xx) { | 874 | if (index == PLLS_I9xx) { |
876 | p2 = (p % 10) ? 1 : 0; | 875 | p2 = (p % 10) ? 1 : 0; |
@@ -882,27 +881,23 @@ splitp(int index, unsigned int p, unsigned int *retp1, unsigned int *retp2) | |||
882 | return 0; | 881 | return 0; |
883 | } | 882 | } |
884 | 883 | ||
885 | if (index == PLLS_I8xx) { | 884 | if (p % 4 == 0) |
886 | if (p % 4 == 0) | 885 | p2 = 1; |
887 | p2 = 1; | 886 | else |
888 | else | 887 | p2 = 0; |
889 | p2 = 0; | 888 | p1 = (p / (1 << (p2 + 1))) - 2; |
889 | if (p % 4 == 0 && p1 < pll->min_p1) { | ||
890 | p2 = 0; | ||
890 | p1 = (p / (1 << (p2 + 1))) - 2; | 891 | p1 = (p / (1 << (p2 + 1))) - 2; |
891 | if (p % 4 == 0 && p1 < plls[index].min_p1) { | ||
892 | p2 = 0; | ||
893 | p1 = (p / (1 << (p2 + 1))) - 2; | ||
894 | } | ||
895 | if (p1 < plls[index].min_p1 || | ||
896 | p1 > plls[index].max_p1 || | ||
897 | (p1 + 2) * (1 << (p2 + 1)) != p) { | ||
898 | return 1; | ||
899 | } else { | ||
900 | *retp1 = (unsigned int)p1; | ||
901 | *retp2 = (unsigned int)p2; | ||
902 | return 0; | ||
903 | } | ||
904 | } | 892 | } |
905 | return 1; | 893 | if (p1 < pll->min_p1 || p1 > pll->max_p1 || |
894 | (p1 + 2) * (1 << (p2 + 1)) != p) { | ||
895 | return 1; | ||
896 | } else { | ||
897 | *retp1 = (unsigned int)p1; | ||
898 | *retp2 = (unsigned int)p2; | ||
899 | return 0; | ||
900 | } | ||
906 | } | 901 | } |
907 | 902 | ||
908 | static int | 903 | static int |
@@ -952,7 +947,7 @@ calc_pll_params(int index, int clock, u32 *retm1, u32 *retm2, u32 *retn, u32 *re | |||
952 | m = pll->max_m - 1; | 947 | m = pll->max_m - 1; |
953 | for (testm = m - 1; testm <= m; testm++) { | 948 | for (testm = m - 1; testm <= m; testm++) { |
954 | f_out = calc_vclock3(index, m, n, p); | 949 | f_out = calc_vclock3(index, m, n, p); |
955 | if (splitm(index, m, &m1, &m2)) { | 950 | if (splitm(index, testm, &m1, &m2)) { |
956 | WRN_MSG("cannot split m = %d\n", m); | 951 | WRN_MSG("cannot split m = %d\n", m); |
957 | n++; | 952 | n++; |
958 | continue; | 953 | continue; |
@@ -963,7 +958,7 @@ calc_pll_params(int index, int clock, u32 *retm1, u32 *retm2, u32 *retn, u32 *re | |||
963 | f_err = f_out - clock + 1; | 958 | f_err = f_out - clock + 1; |
964 | 959 | ||
965 | if (f_err < err_best) { | 960 | if (f_err < err_best) { |
966 | m_best = m; | 961 | m_best = testm; |
967 | n_best = n; | 962 | n_best = n; |
968 | p_best = p; | 963 | p_best = p; |
969 | f_best = f_out; | 964 | f_best = f_out; |