OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-arm/] [arch-riscstation/] [acornfb.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
2
 *  linux/include/asm-arm/arch-rpc/acornfb.h
3
 *
4
 *  Copyright (C) 1999 Russell King
5
 *  Copyright (C) 2002 Simtec Electronics / Ben Dooks / Vincent Sanders
6
 *
7
 * This program is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License version 2 as
9
 * published by the Free Software Foundation.
10
 *
11
 *  AcornFB architecture specific code
12
 */
13
 
14
#define acornfb_valid_pixrate(rate) (1)
15
 
16
/*
17
 * Try to find the best PLL parameters for the pixel clock.
18
 * This algorithm seems to give best predictable results,
19
 * and produces the same values as detailed in the VIDC20
20
 * data sheet.
21
 */
22
static inline u_int
23
acornfb_vidc20_find_pll(u_int pixclk)
24
{
25
        u_int r, best_r = 2, best_v = 2;
26
        int best_d = 0x7fffffff;
27
 
28
        for (r = 2; r <= 32; r++) {
29
                u_int rr, v, p;
30
                int d;
31
 
32
                rr = 31250 * r;
33
 
34
                v = (rr + pixclk / 2) / pixclk;
35
 
36
                if (v > 32 || v < 2)
37
                        continue;
38
 
39
                p = (rr + v / 2) / v;
40
 
41
                d = pixclk - p;
42
 
43
                if (d < 0)
44
                        d = -d;
45
 
46
                if (d < best_d) {
47
                        best_d = d;
48
                        best_v = v - 1;
49
                        best_r = r - 1;
50
                }
51
 
52
                if (d == 0)
53
                        break;
54
        }
55
 
56
        return best_v << 8 | best_r;
57
}
58
 
59
static inline void
60
acornfb_vidc20_find_rates(struct vidc_timing *vidc,
61
                          struct fb_var_screeninfo *var)
62
{
63
        u_int div, bandwidth;
64
 
65
        /* Select pixel-clock divisor to keep PLL in range */
66
        div = var->pixclock / 9090; /*9921*/
67
 
68
        /* Limit divisor */
69
        if (div == 0)
70
                div = 1;
71
        if (div > 8)
72
                div = 8;
73
 
74
        /* Encode divisor to VIDC20 setting */
75
        switch (div) {
76
        case 1: vidc->control |= VIDC20_CTRL_PIX_CK;  break;
77
        case 2: vidc->control |= VIDC20_CTRL_PIX_CK2; break;
78
        case 3: vidc->control |= VIDC20_CTRL_PIX_CK3; break;
79
        case 4: vidc->control |= VIDC20_CTRL_PIX_CK4; break;
80
        case 5: vidc->control |= VIDC20_CTRL_PIX_CK5; break;
81
        case 6: vidc->control |= VIDC20_CTRL_PIX_CK6; break;
82
        case 7: vidc->control |= VIDC20_CTRL_PIX_CK7; break;
83
        case 8: vidc->control |= VIDC20_CTRL_PIX_CK8; break;
84
        }
85
 
86
        /* Calculate bandwidth */
87
        bandwidth = var->pixclock * 8 / var->bits_per_pixel;
88
 
89
        /* Encode bandwidth as VIDC20 setting */
90
        if (bandwidth > 33334)
91
                vidc->control |= VIDC20_CTRL_FIFO_16;   /* < 30.0MB/s */
92
        else if (bandwidth > 26666)
93
                vidc->control |= VIDC20_CTRL_FIFO_20;   /* < 37.5MB/s */
94
        else if (bandwidth > 22222)
95
                vidc->control |= VIDC20_CTRL_FIFO_24;   /* < 45.0MB/s */
96
        else
97
                vidc->control |= VIDC20_CTRL_FIFO_28;   /* > 45.0MB/s */
98
 
99
        /* Find the PLL values */
100
        vidc->pll_ctl  = acornfb_vidc20_find_pll(var->pixclock / div);
101
}
102
 
103
#define acornfb_default_control()       (VIDC20_CTRL_PIX_VCLK)
104
#define acornfb_default_econtrol()      (VIDC20_ECTL_DAC | VIDC20_ECTL_REG(3))

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.