annotate drivers/radeon/radeonfb.c @ 10267:d953763cc555

libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>: Make sure that altivec gets enabled in libmpeg2
author arpi
date Mon, 09 Jun 2003 12:10:42 +0000
parents b57a0f03627f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2 * drivers/video/radeonfb.c
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3 * framebuffer driver for ATI Radeon chipset video boards
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
4 *
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
5 * Copyright 2000 Ani Joshi <ajoshi@unixbox.com>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
6 *
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
7 *
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
8 * ChangeLog:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
9 * 2000-08-03 initial version 0.0.1
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
10 * 2000-09-10 more bug fixes, public release 0.0.5
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
11 * 2001-02-19 mode bug fixes, 0.0.7
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
12 * 2001-07-05 fixed scrolling issues, engine initialization,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
13 * and minor mode tweaking, 0.0.9
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
14 *
1912
33afcb62fc64 Radeon VE support
nick
parents: 1911
diff changeset
15 * 2001-09-07 Radeon VE support
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
16 * 2001-09-10 Radeon VE QZ support by Nick Kurshev <nickols_k@mail.ru>
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
17 * (limitations: on dualhead Radeons (VE, M6, M7)
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
18 * driver works only on second head (DVI port).
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
19 * TVout is not supported too. M6 & M7 chips
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
20 * currently are not supported. Driver has a lot
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
21 * of other bugs. Probably they can be solved by
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
22 * importing XFree86 code, which has ATI's support).,
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
23 * 0.0.11
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
24 * 2001-09-13 merge Ani Joshi radeonfb-0.1.0:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
25 * console switching fixes, blanking fixes,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
26 * 0.1.0-ve.0
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
27 * 2001-09-18 Radeon VE, M6 support (by Nick Kurshev <nickols_k@mail.ru>),
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
28 * Fixed bug of rom bios detection on VE (by NK),
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
29 * Minor code cleanup (by NK),
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
30 * Enable CRT port on VE (by NK),
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
31 * Disable SURFACE_CNTL because mplayer doesn't work
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
32 * propertly (by NK)
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
33 * 0.1.0-ve.1
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
34 * 2001-09-25 MTRR support (by NK)
1966
9d528800f110 malloc.h -> slab.h
nick
parents: 1951
diff changeset
35 * 0.1.0-ve.2
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
36 * 2001-12-17 sync with 0.1.1:
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
37 * PanelYRes - module parameter
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
38 * - rage theatre (please see gatos.sf.net)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
39 * - buggy tvout detection (need radeon_i2c)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
40 * + better powerpc support
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
41 * + better radeon2 pll computing
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
42 * * Note: my stuff still work better for me than official
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
43 * linux driver :(
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
44 * Special thanks to ATI DevRel team for their hardware donations.
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
45 *
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
46 * LIMITATIONS: on dualhead Radeons (VE, M6, M7) driver doesn't work in
1916
7c36fd5e6d22 Comments cleanup
nick
parents: 1915
diff changeset
47 * dual monitor configuration. TVout is not supported too.
7c36fd5e6d22 Comments cleanup
nick
parents: 1915
diff changeset
48 * Probably these problems can be solved by importing XFree86 code, which
7c36fd5e6d22 Comments cleanup
nick
parents: 1915
diff changeset
49 * has ATI's support.
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
50 *
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
51 * Mini-HOWTO: This driver doesn't accept any options. It only switches your
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
52 * video card to graphics mode. Standard way to change video modes and other
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
53 * video attributes is using 'fbset' utility.
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
54 * Sample:
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
55 *
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
56 * #!/bin/sh
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
57 * fbset -fb /dev/fb0 -xres 640 -yres 480 -depth 32 -vxres 640 -vyres 480 -left 70 -right 50 -upper 70 -lower 70 -laced false -pixclock 39767
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
58 *
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
59 */
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
60
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
61 #define RADEON_VERSION "0.1.1-ve"
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
62
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
63 #include <linux/config.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
64 #include <linux/module.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
65 #include <linux/kernel.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
66 #include <linux/errno.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
67 #include <linux/string.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
68 #include <linux/mm.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
69 #include <linux/tty.h>
1966
9d528800f110 malloc.h -> slab.h
nick
parents: 1951
diff changeset
70 #include <linux/slab.h>
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
71 #include <linux/delay.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
72 #include <linux/fb.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
73 #include <linux/console.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
74 #include <linux/selection.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
75 #include <linux/ioport.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
76 #include <linux/init.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
77 #include <linux/pci.h>
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
78 #include <linux/unistd.h>
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
79
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
80 #include <asm/io.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
81
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
82 #include <video/fbcon.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
83 #include <video/fbcon-cfb8.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
84 #include <video/fbcon-cfb16.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
85 #include <video/fbcon-cfb24.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
86 #include <video/fbcon-cfb32.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
87
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
88 #ifdef CONFIG_MTRR
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
89 #include <asm/mtrr.h>
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
90 #endif
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
91 #if defined(__powerpc__)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
92 #include <asm/prom.h>
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
93 #endif
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
94
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
95 #include "radeon.h"
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
96
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
97
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
98 #define DEBUG 0
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
99
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
100 #if DEBUG
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
101 #define RTRACE printk
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
102 #else
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
103 #define RTRACE(...) ((void)0)
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
104 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
105
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
106 MODULE_AUTHOR("Ani Joshi. (Radeon VE extensions by Nick Kurshev)");
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
107 MODULE_DESCRIPTION("framebuffer driver for ATI Radeon chipset. Ver: "RADEON_VERSION);
9588
b57a0f03627f add MODULE_LICENSE
arpi
parents: 8941
diff changeset
108 #ifdef MODULE_LICENSE
b57a0f03627f add MODULE_LICENSE
arpi
parents: 8941
diff changeset
109 MODULE_LICENSE("GPL");
b57a0f03627f add MODULE_LICENSE
arpi
parents: 8941
diff changeset
110 #endif
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
111 #ifdef CONFIG_MTRR
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
112 MODULE_PARM(nomtrr, "i");
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
113 MODULE_PARM_DESC(nomtrr, "Don't touch MTRR (touch=0(default))");
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
114 #endif
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
115 MODULE_PARM(yres_panel, "i");
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
116 MODULE_PARM_DESC(yres_panel, "Force DFP height");
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
117
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
118
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
119 enum radeon_chips {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
120 RADEON_QD,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
121 RADEON_QE,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
122 RADEON_QF,
1912
33afcb62fc64 Radeon VE support
nick
parents: 1911
diff changeset
123 RADEON_QG,
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
124 RADEON_QY,
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
125 RADEON_QZ,
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
126 RADEON_LY,
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
127 RADEON_LZ,
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
128 RADEON_LW,
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
129 R200_QL,
3940
db3a8c95bcf7 Added support of Radeon2 8500 AIW
nick
parents: 3555
diff changeset
130 R200_BB,
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
131 RV200_QW
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
132 };
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
133
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
134 enum radeon_montype
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
135 {
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
136 MT_NONE,
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
137 MT_CRT, /* CRT-(cathode ray tube) analog monitor. (15-pin VGA connector) */
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
138 MT_LCD, /* Liquid Crystal Display */
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
139 MT_DFP, /* DFP-digital flat panel monitor. (24-pin DVI-I connector) */
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
140 MT_CTV, /* Composite TV out (not in VE) */
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
141 MT_STV /* S-Video TV out (probably in VE only) */
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
142 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
143
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
144 static struct pci_device_id radeonfb_pci_table[] __devinitdata = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
145 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_QD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_QD},
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
146 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_QE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_QE},
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
147 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_QF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_QF},
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
148 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_QG, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_QG},
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
149 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_QY, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_QY},
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
150 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_QZ, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_QZ},
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
151 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_LY, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_LY},
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
152 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_LZ, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_LZ},
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
153 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_LW, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_LW},
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
154 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_R200_QL, PCI_ANY_ID, PCI_ANY_ID, 0, 0, R200_QL},
3940
db3a8c95bcf7 Added support of Radeon2 8500 AIW
nick
parents: 3555
diff changeset
155 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_R200_BB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, R200_BB},
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
156 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RV200_QW, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RV200_QW},
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
157 { 0, }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
158 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
159 MODULE_DEVICE_TABLE(pci, radeonfb_pci_table);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
160
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
161
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
162 typedef struct {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
163 u16 reg;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
164 u32 val;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
165 } reg_val;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
166
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
167
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
168 #define COMMON_REGS_SIZE = (sizeof(common_regs)/sizeof(common_regs[0]))
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
169
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
170 typedef struct {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
171 u8 clock_chip_type;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
172 u8 struct_size;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
173 u8 accelerator_entry;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
174 u8 VGA_entry;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
175 u16 VGA_table_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
176 u16 POST_table_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
177 u16 XCLK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
178 u16 MCLK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
179 u8 num_PLL_blocks;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
180 u8 size_PLL_blocks;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
181 u16 PCLK_ref_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
182 u16 PCLK_ref_divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
183 u32 PCLK_min_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
184 u32 PCLK_max_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
185 u16 MCLK_ref_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
186 u16 MCLK_ref_divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
187 u32 MCLK_min_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
188 u32 MCLK_max_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
189 u16 XCLK_ref_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
190 u16 XCLK_ref_divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
191 u32 XCLK_min_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
192 u32 XCLK_max_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
193 } __attribute__ ((packed)) PLL_BLOCK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
194
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
195
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
196 struct pll_info {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
197 int ppll_max;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
198 int ppll_min;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
199 int xclk;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
200 int ref_div;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
201 int ref_clk;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
202 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
203
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
204
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
205 struct ram_info {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
206 int ml;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
207 int mb;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
208 int trcd;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
209 int trp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
210 int twr;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
211 int cl;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
212 int tr2w;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
213 int loop_latency;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
214 int rloop;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
215 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
216
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
217
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
218 struct radeon_regs {
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
219 /* Common registers */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
220 u32 ovr_clr;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
221 u32 ovr_wid_left_right;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
222 u32 ovr_wid_top_bottom;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
223 u32 ov0_scale_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
224 u32 mpp_tb_config;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
225 u32 mpp_gp_config;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
226 u32 subpic_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
227 u32 i2c_cntl_1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
228 u32 gen_int_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
229 u32 cap0_trig_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
230 u32 cap1_trig_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
231 u32 bus_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
232 /* Other registers to save for VT switches */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
233 u32 dp_datatype;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
234 u32 rbbm_soft_reset;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
235 u32 clock_cntl_index;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
236 u32 amcgpio_en_reg;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
237 u32 amcgpio_mask;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
238 /* CRTC registers */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
239 u32 crtc_gen_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
240 u32 crtc_ext_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
241 u32 dac_cntl;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
242 u32 crtc_h_total_disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
243 u32 crtc_h_sync_strt_wid;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
244 u32 crtc_v_total_disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
245 u32 crtc_v_sync_strt_wid;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
246 u32 crtc_offset;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
247 u32 crtc_offset_cntl;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
248 u32 crtc_pitch;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
249 /* CRTC2 registers */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
250 u32 crtc2_gen_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
251 u32 dac2_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
252 u32 disp_output_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
253 u32 crtc2_h_total_disp;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
254 u32 crtc2_h_sync_strt_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
255 u32 crtc2_v_total_disp;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
256 u32 crtc2_v_sync_strt_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
257 u32 crtc2_offset;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
258 u32 crtc2_offset_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
259 u32 crtc2_pitch;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
260 /* Flat panel registers */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
261 u32 fp_crtc_h_total_disp;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
262 u32 fp_crtc_v_total_disp;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
263 u32 fp_gen_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
264 u32 fp_h_sync_strt_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
265 u32 fp_horz_stretch;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
266 u32 fp_panel_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
267 u32 fp_v_sync_strt_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
268 u32 fp_vert_stretch;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
269 u32 lvds_gen_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
270 u32 lvds_pll_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
271 u32 tmds_crc;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
272 /* DDA registers */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
273 u32 dda_config;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
274 u32 dda_on_off;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
275
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
276 /* Computed values for PLL */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
277 u32 dot_clock_freq;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
278 u32 pll_output_freq;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
279 int feedback_div;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
280 int post_div;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
281 /* PLL registers */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
282 u32 ppll_ref_div;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
283 u32 ppll_div_3;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
284 u32 htotal_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
285 /* Computed values for PLL2 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
286 u32 dot_clock_freq_2;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
287 u32 pll_output_freq_2;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
288 int feedback_div_2;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
289 int post_div_2;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
290 /* PLL2 registers */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
291 u32 p2pll_ref_div;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
292 u32 p2pll_div_0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
293 u32 htotal_cntl2;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
294 /* Pallet */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
295 int palette_valid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
296 u32 palette[256];
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
297 u32 palette2[256];
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
298
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
299 u32 flags;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
300 u32 pix_clock;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
301 int xres, yres;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
302 int bpp;
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
303 #if defined(__BIG_ENDIAN)
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
304 u32 surface_cntl;
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
305 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
306 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
307
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
308
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
309 struct radeonfb_info {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
310 struct fb_info info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
311
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
312 struct radeon_regs state;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
313 struct radeon_regs init_state;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
314
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
315 char name[17];
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
316 char ram_type[12];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
317
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
318 int hasCRTC2;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
319 int crtDispType;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
320 int dviDispType;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
321 int isM7;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
322 int isM6;
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
323 int isR200;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
324 /* Computed values for FPs */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
325 int PanelXRes;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
326 int PanelYRes;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
327 int HOverPlus;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
328 int HSyncWidth;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
329 int HBlank;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
330 int VOverPlus;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
331 int VSyncWidth;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
332 int VBlank;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
333 int PanelPwrDly;
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
334
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
335 u32 mmio_base_phys;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
336 u32 fb_base_phys;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
337
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
338 u32 mmio_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
339 u32 fb_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
340
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
341 u32 MemCntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
342 u32 BusCntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
343
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
344 struct pci_dev *pdev;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
345
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
346 struct display disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
347 int currcon;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
348 struct display *currcon_display;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
349
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
350 struct { u8 red, green, blue, pad; } palette[256];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
351
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
352 int chipset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
353 int video_ram;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
354 u8 rev;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
355 int pitch, bpp, depth;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
356 int xres, yres, pixclock;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
357
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
358 u32 dp_gui_master_cntl;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
359
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
360 struct pll_info pll;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
361 int pll_output_freq, post_div, fb_div;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
362
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
363 struct ram_info ram;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
364
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
365 #ifdef CONFIG_MTRR
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
366 struct { int vram; int vram_valid; } mtrr;
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
367 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
368 #if defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
369 union {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
370 #if defined(FBCON_HAS_CFB16)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
371 u_int16_t cfb16[16];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
372 #endif
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
373 #if defined(FBCON_HAS_CFB24)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
374 u_int32_t cfb24[16];
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
375 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
376 #if defined(FBCON_HAS_CFB32)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
377 u_int32_t cfb32[16];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
378 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
379 } con_cmap;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
380 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
381 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
382
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
383 #define SINGLE_MONITOR(rinfo) (rinfo->crtDispType == MT_NONE || rinfo->dviDispType == MT_NONE)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
384 /*#define DUAL_MONITOR(rinfo) (rinfo->crtDispType != MT_NONE && rinfo->dviDispType != MT_NONE)*/
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
385 /* Disable DUAL monitor support for now */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
386 #define DUAL_MONITOR(rinfo) (0)
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
387 #define PRIMARY_MONITOR(rinfo) (rinfo->dviDispType != MT_NONE &&\
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
388 rinfo->dviDispType != MT_STV &&\
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
389 rinfo->dviDispType != MT_CTV ?\
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
390 rinfo->dviDispType : rinfo->crtDispType)
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
391
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
392 static struct fb_var_screeninfo radeonfb_default_var = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
393 640, 480, 640, 480, 0, 0, 8, 0,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
394 {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0},
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
395 0, 0, -1, -1, 0, 39721, 40, 24, 32, 11, 96, 2,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
396 0, FB_VMODE_NONINTERLACED
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
397 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
398
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
399
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
400 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
401 * IO macros
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
402 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
403
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
404 #define INREG8(addr) readb((rinfo->mmio_base)+addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
405 #define OUTREG8(addr,val) writeb(val, (rinfo->mmio_base)+addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
406 #define INREG(addr) readl((rinfo->mmio_base)+addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
407 #define OUTREG(addr,val) writel(val, (rinfo->mmio_base)+addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
408
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
409 #define OUTPLL(addr,val) OUTREG8(CLOCK_CNTL_INDEX, (addr & 0x0000001f) | 0x00000080); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
410 OUTREG(CLOCK_CNTL_DATA, val)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
411 #define OUTPLLP(addr,val,mask) \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
412 do { \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
413 unsigned int _tmp = INPLL(addr); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
414 _tmp &= (mask); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
415 _tmp |= (val); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
416 OUTPLL(addr, _tmp); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
417 } while (0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
418
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
419 #define OUTREGP(addr,val,mask) \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
420 do { \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
421 unsigned int _tmp = INREG(addr); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
422 _tmp &= (mask); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
423 _tmp |= (val); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
424 OUTREG(addr, _tmp); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
425 } while (0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
426
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
427
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
428 static __inline__ u32 _INPLL(struct radeonfb_info *rinfo, u32 addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
429 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
430 OUTREG8(CLOCK_CNTL_INDEX, addr & 0x0000001f);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
431 return (INREG(CLOCK_CNTL_DATA));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
432 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
433
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
434 #define INPLL(addr) _INPLL(rinfo, addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
435
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
436 static __inline__ u8 radeon_get_post_div_bitval(int post_div)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
437 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
438 switch (post_div) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
439 case 1:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
440 return 0x00;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
441 case 2:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
442 return 0x01;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
443 case 3:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
444 return 0x04;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
445 case 4:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
446 return 0x02;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
447 case 6:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
448 return 0x06;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
449 case 8:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
450 return 0x03;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
451 case 12:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
452 return 0x07;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
453 default:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
454 return 0x02;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
455 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
456 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
457
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
458
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
459
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
460 static __inline__ int round_div(int num, int den)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
461 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
462 return (num + (den / 2)) / den;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
463 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
464
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
465
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
466
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
467 static __inline__ int min_bits_req(int val)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
468 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
469 int bits_req = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
470
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
471 if (val == 0)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
472 bits_req = 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
473
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
474 while (val) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
475 val >>= 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
476 bits_req++;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
477 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
478
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
479 return (bits_req);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
480 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
481
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
482
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
483 static __inline__ int _max(int val1, int val2)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
484 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
485 if (val1 >= val2)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
486 return val1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
487 else
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
488 return val2;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
489 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
490
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
491
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
492 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
493 * 2D engine routines
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
494 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
495
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
496 static __inline__ void radeon_engine_flush (struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
497 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
498 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
499
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
500 /* initiate flush */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
501 OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
502 ~RB2D_DC_FLUSH_ALL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
503
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
504 for (i=0; i < 2000000; i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
505 if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
506 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
507 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
508 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
509
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
510
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
511 static __inline__ void _radeon_fifo_wait (struct radeonfb_info *rinfo, int entries)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
512 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
513 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
514
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
515 for (i=0; i<2000000; i++)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
516 if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
517 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
518 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
519
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
520
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
521 static __inline__ void _radeon_engine_idle (struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
522 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
523 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
524
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
525 /* ensure FIFO is empty before waiting for idle */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
526 _radeon_fifo_wait (rinfo, 64);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
527
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
528 for (i=0; i<2000000; i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
529 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
530 radeon_engine_flush (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
531 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
532 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
533 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
534 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
535
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
536
2037
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
537
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
538 #define radeon_engine_idle() _radeon_engine_idle(rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
539 #define radeon_fifo_wait(entries) _radeon_fifo_wait(rinfo,entries)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
540
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
541
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
542
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
543 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
544 * helper routines
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
545 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
546
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
547 static __inline__ u32 radeon_get_dstbpp(u16 depth)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
548 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
549 switch (depth) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
550 case 8:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
551 return DST_8BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
552 case 15:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
553 return DST_15BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
554 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
555 return DST_16BPP;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
556 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
557 return DST_24BPP;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
558 case 32:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
559 return DST_32BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
560 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
561 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
562 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
563 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
564
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
565
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
566 static void _radeon_engine_reset(struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
567 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
568 u32 clock_cntl_index, mclk_cntl, rbbm_soft_reset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
569
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
570 radeon_engine_flush (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
571
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
572 clock_cntl_index = INREG(CLOCK_CNTL_INDEX);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
573 mclk_cntl = INPLL(MCLK_CNTL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
574
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
575 OUTPLL(MCLK_CNTL, (mclk_cntl |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
576 FORCEON_MCLKA |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
577 FORCEON_MCLKB |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
578 FORCEON_YCLKA |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
579 FORCEON_YCLKB |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
580 FORCEON_MC |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
581 FORCEON_AIC));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
582 rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
583
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
584 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
585 SOFT_RESET_CP |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
586 SOFT_RESET_HI |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
587 SOFT_RESET_SE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
588 SOFT_RESET_RE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
589 SOFT_RESET_PP |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
590 SOFT_RESET_E2 |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
591 SOFT_RESET_RB |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
592 SOFT_RESET_HDP);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
593 INREG(RBBM_SOFT_RESET);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
594 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset & (u32)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
595 ~(SOFT_RESET_CP |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
596 SOFT_RESET_HI |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
597 SOFT_RESET_SE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
598 SOFT_RESET_RE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
599 SOFT_RESET_PP |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
600 SOFT_RESET_E2 |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
601 SOFT_RESET_RB |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
602 SOFT_RESET_HDP));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
603 INREG(RBBM_SOFT_RESET);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
604
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
605 OUTPLL(MCLK_CNTL, mclk_cntl);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
606 OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
607 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
608
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
609 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
610 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
611
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
612 #define radeon_engine_reset() _radeon_engine_reset(rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
613
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
614 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
615 * globals
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
616 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
617
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
618 static char fontname[40] __initdata;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
619 static char *mode_option __initdata;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
620 static char noaccel __initdata = 0;
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
621 static int nomtrr __initdata = 0;
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
622 static int yres_panel __initdata = 0;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
623 static char panel_yres __initdata = 0;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
624
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
625 #if 0
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
626 #ifdef FBCON_HAS_CFB8
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
627 static struct display_switch fbcon_radeon8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
628 #endif
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
629 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
630
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
631 #ifdef CONFIG_MTRR
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
632 static int mtrr = 1;
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
633 #endif
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
634
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
635 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
636 * prototypes
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
637 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
638
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
639 static int radeonfb_get_fix (struct fb_fix_screeninfo *fix, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
640 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
641 static int radeonfb_get_var (struct fb_var_screeninfo *var, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
642 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
643 static int radeonfb_set_var (struct fb_var_screeninfo *var, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
644 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
645 static int radeonfb_get_cmap (struct fb_cmap *cmap, int kspc, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
646 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
647 static int radeonfb_set_cmap (struct fb_cmap *cmap, int kspc, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
648 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
649 static int radeonfb_pan_display (struct fb_var_screeninfo *var, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
650 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
651 static int radeonfb_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
652 unsigned long arg, int con, struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
653 static int radeonfb_switch (int con, struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
654 static int radeonfb_updatevar (int con, struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
655 static void radeonfb_blank (int blank, struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
656 static int radeon_get_cmap_len (const struct fb_var_screeninfo *var);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
657 static int radeon_getcolreg (unsigned regno, unsigned *red, unsigned *green,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
658 unsigned *blue, unsigned *transp,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
659 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
660 static int radeon_setcolreg (unsigned regno, unsigned red, unsigned green,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
661 unsigned blue, unsigned transp, struct fb_info *info);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
662 static void radeon_set_dispsw (struct radeonfb_info *rinfo, struct display *disp);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
663 static void radeon_save_mode (struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
664 struct radeon_regs *save);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
665 static void radeon_save_state (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
666 struct radeon_regs *save);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
667 static void radeon_engine_init (struct radeonfb_info *rinfo);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
668 static int radeon_load_video_mode (struct radeonfb_info *rinfo,
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
669 struct fb_var_screeninfo *mode);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
670 static void radeon_write_mode (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
671 struct radeon_regs *mode);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
672 static void radeon_write_state (struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
673 struct radeon_regs *mode);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
674 static int __devinit radeon_set_fbinfo (struct radeonfb_info *rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
675 static int __devinit radeon_init_disp (struct radeonfb_info *rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
676 static int radeon_init_disp_var (struct radeonfb_info *rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
677 static int radeonfb_pci_register (struct pci_dev *pdev,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
678 const struct pci_device_id *ent);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
679 static void __devexit radeonfb_pci_unregister (struct pci_dev *pdev);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
680 static char *radeon_find_rom(struct radeonfb_info *rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
681 static void radeon_get_pllinfo(struct radeonfb_info *rinfo, char *bios_seg);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
682 static void do_install_cmap(int con, struct fb_info *info);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
683 static int radeonfb_do_maximize(struct radeonfb_info *rinfo,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
684 struct fb_var_screeninfo *var,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
685 struct fb_var_screeninfo *v,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
686 int nom, int den);
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
687 #if defined(__powerpc__)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
688 extern struct device_node *pci_device_to_OF_node(struct pci_dev *dev);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
689 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
690
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
691 static struct fb_ops radeon_fb_ops = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
692 fb_get_fix: radeonfb_get_fix,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
693 fb_get_var: radeonfb_get_var,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
694 fb_set_var: radeonfb_set_var,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
695 fb_get_cmap: radeonfb_get_cmap,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
696 fb_set_cmap: radeonfb_set_cmap,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
697 fb_pan_display: radeonfb_pan_display,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
698 fb_ioctl: radeonfb_ioctl,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
699 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
700
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
701
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
702 static struct pci_driver radeonfb_driver = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
703 name: "radeonfb",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
704 id_table: radeonfb_pci_table,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
705 probe: radeonfb_pci_register,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
706 remove: radeonfb_pci_unregister,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
707 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
708
2037
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
709 static void _radeon_wait_for_idle(struct radeonfb_info *rinfo);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
710 /* Restore the acceleration hardware to its previous state. */
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
711 static void _radeon_engine_restore(struct radeonfb_info *rinfo)
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
712 {
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
713 int pitch64;
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
714
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
715 radeon_fifo_wait(1);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
716 /* turn of all automatic flushing - we'll do it all */
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
717 OUTREG(RB2D_DSTCACHE_MODE, 0);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
718
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
719 pitch64 = ((rinfo->xres * (rinfo->bpp / 8) + 0x3f)) >> 6;
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
720
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
721 radeon_fifo_wait(1);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
722 OUTREG(DEFAULT_OFFSET, (INREG(DEFAULT_OFFSET) & 0xC0000000) |
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
723 (pitch64 << 22));
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
724
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
725 radeon_fifo_wait(1);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
726 #if defined(__BIG_ENDIAN)
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
727 OUTREGP(DP_DATATYPE,
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
728 HOST_BIG_ENDIAN_EN, ~HOST_BIG_ENDIAN_EN);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
729 #else
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
730 OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
731 #endif
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
732
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
733 radeon_fifo_wait(1);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
734 OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
735 | DEFAULT_SC_BOTTOM_MAX));
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
736 radeon_fifo_wait(1);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
737 OUTREG(DP_GUI_MASTER_CNTL, (INREG(DP_GUI_MASTER_CNTL)
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
738 | GMC_BRUSH_SOLID_COLOR
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
739 | GMC_SRC_DATATYPE_COLOR));
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
740
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
741 radeon_fifo_wait(7);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
742 OUTREG(DST_LINE_START, 0);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
743 OUTREG(DST_LINE_END, 0);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
744 OUTREG(DP_BRUSH_FRGD_CLR, 0xffffffff);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
745 OUTREG(DP_BRUSH_BKGD_CLR, 0x00000000);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
746 OUTREG(DP_SRC_FRGD_CLR, 0xffffffff);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
747 OUTREG(DP_SRC_BKGD_CLR, 0x00000000);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
748 OUTREG(DP_WRITE_MASK, 0xffffffff);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
749
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
750 _radeon_wait_for_idle(rinfo);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
751 }
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
752
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
753 /* The FIFO has 64 slots. This routines waits until at least `entries' of
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
754 these slots are empty. */
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
755 #define RADEON_TIMEOUT 2000000 /* Fall out of wait loops after this count */
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
756 static void _radeon_wait_for_fifo_function(struct radeonfb_info *rinfo, int entries)
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
757 {
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
758 int i;
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
759
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
760 for (;;) {
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
761 for (i = 0; i < RADEON_TIMEOUT; i++) {
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
762 if((INREG(RBBM_STATUS) & RBBM_FIFOCNT_MASK) >= entries) return;
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
763 }
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
764 radeon_engine_reset();
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
765 _radeon_engine_restore(rinfo);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
766 /* it might be that DRI has been compiled in, but corresponding
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
767 library was not loaded.. */
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
768 }
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
769 }
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
770 /* Wait for the graphics engine to be completely idle: the FIFO has
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
771 drained, the Pixel Cache is flushed, and the engine is idle. This is a
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
772 standard "sync" function that will make the hardware "quiescent". */
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
773 static void _radeon_wait_for_idle(struct radeonfb_info *rinfo)
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
774 {
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
775 int i;
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
776
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
777 _radeon_wait_for_fifo_function(rinfo, 64);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
778
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
779 for (;;) {
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
780 for (i = 0; i < RADEON_TIMEOUT; i++) {
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
781 if (!(INREG(RBBM_STATUS) & RBBM_ACTIVE)) {
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
782 radeon_engine_flush(rinfo);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
783 return;
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
784 }
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
785 }
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
786 _radeon_engine_reset(rinfo);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
787 _radeon_engine_restore(rinfo);
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
788 }
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
789 }
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
790
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
791 int __init radeonfb_init (void)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
792 {
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
793 #ifdef CONFIG_MTRR
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
794 if (nomtrr) {
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
795 mtrr = 0;
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
796 printk("radeonfb: Parameter NOMTRR set\n");
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
797 }
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
798 #endif
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
799 if (yres_panel) panel_yres = yres_panel;
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
800 return pci_module_init (&radeonfb_driver);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
801 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
802
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
803
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
804 void __exit radeonfb_exit (void)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
805 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
806 pci_unregister_driver (&radeonfb_driver);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
807 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
808
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
809
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
810 int __init radeonfb_setup (char *options)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
811 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
812 char *this_opt;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
813
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
814 if (!options || !*options)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
815 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
816
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
817 while ((this_opt = strsep (&options, ",")) != NULL) {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
818 if (!*this_opt)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
819 continue;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
820 if (!strncmp (this_opt, "font:", 5)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
821 char *p;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
822 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
823
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
824 p = this_opt + 5;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
825 for (i=0; i<sizeof (fontname) - 1; i++)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
826 if (!*p || *p == ' ' || *p == ',')
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
827 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
828 memcpy(fontname, this_opt + 5, i);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
829 } else if (!strncmp(this_opt, "noaccel", 7)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
830 noaccel = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
831 }
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
832 #ifdef CONFIG_MTRR
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
833 else if(!strncmp(this_opt, "nomtrr", 6)) {
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
834 mtrr = 0;
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
835 }
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
836 #endif
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
837 else if (!strncmp(this_opt, "panel_yres:", 11)) {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
838 panel_yres = simple_strtoul((this_opt+11), NULL, 0);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
839 } else
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
840 mode_option = this_opt;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
841 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
842
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
843 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
844 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
845
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
846 #ifdef MODULE
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
847 module_init(radeonfb_init);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
848 module_exit(radeonfb_exit);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
849 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
850
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
851 static char * GET_MON_NAME(int type)
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
852 {
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
853 char *pret;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
854 switch(type)
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
855 {
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
856 case MT_NONE: pret = "no"; break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
857 case MT_CRT: pret = "CRT"; break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
858 case MT_DFP: pret = "DFP"; break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
859 case MT_LCD: pret = "LCD"; break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
860 case MT_CTV: pret = "CTV"; break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
861 case MT_STV: pret = "STV"; break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
862 default: pret = "Unknown";
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
863 }
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
864 return pret;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
865 }
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
866
2135
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
867 /*This funtion is used to reverse calculate
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
868 panel information from register settings in VGA mode.
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
869 More graceful way is to use EDID information... if it can be detected.
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
870 This way may be better than directly probing BIOS image. Because
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
871 BIOS image could change from version to version, while the
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
872 registers should always(?) contain right information, otherwise
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
873 the VGA mode display will not be correct. Well, if someone
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
874 messes up these registers before our driver is loaded, we'll be in
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
875 trouble...*/
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
876 static int radeon_get_dfp_info(struct radeonfb_info *rinfo)
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
877 {
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
878 unsigned long r;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
879 unsigned short a, b;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
880
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
881 if (panel_yres) {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
882 rinfo->PanelYRes = panel_yres;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
883 } else {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
884 r = INREG(FP_VERT_STRETCH);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
885 r &= 0x00fff000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
886 rinfo->PanelYRes = (unsigned short)(r >> 0x0c) + 1;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
887 }
2135
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
888 switch(rinfo->PanelYRes)
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
889 {
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
890 case 480: rinfo->PanelXRes = 640;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
891 break;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
892 case 600: rinfo->PanelXRes = 800;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
893 break;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
894 case 768: rinfo->PanelXRes = 1024;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
895 break;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
896 case 1024: rinfo->PanelXRes = 1280;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
897 break;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
898 case 1050: rinfo->PanelXRes = 1400;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
899 break;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
900 case 1200: rinfo->PanelXRes = 1600;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
901 break;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
902 default:
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
903 printk("radeonfb: Failed to detect the DFP panel size.\n");
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
904 return 0;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
905
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
906 }
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
907
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
908 printk("Detected DFP panel size: %dx%d\n", rinfo->PanelXRes, rinfo->PanelYRes);
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
909
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
910 r = INREG(FP_CRTC_H_TOTAL_DISP);
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
911 a = (r & FP_CRTC_H_TOTAL_MASK) + 4;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
912 b = (r & 0x01FF0000) >> FP_CRTC_H_DISP_SHIFT;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
913 rinfo->HBlank = (a - b + 1) * 8;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
914
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
915 r = INREG(FP_H_SYNC_STRT_WID);
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
916 rinfo->HOverPlus =
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
917 (unsigned short)((r & FP_H_SYNC_STRT_CHAR_MASK)
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
918 >> FP_H_SYNC_STRT_CHAR_SHIFT) - b - 1;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
919 rinfo->HOverPlus *= 8;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
920 rinfo->HSyncWidth =
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
921 (unsigned short)((r & FP_H_SYNC_WID_MASK)
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
922 >> FP_H_SYNC_WID_SHIFT);
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
923 rinfo->HSyncWidth *= 8;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
924 r = INREG(FP_CRTC_V_TOTAL_DISP);
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
925 a = (r & FP_CRTC_V_TOTAL_MASK) + 1;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
926 b = (r & FP_CRTC_V_DISP_MASK) >> FP_CRTC_V_DISP_SHIFT;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
927 rinfo->VBlank = a - b /*+ 24*/;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
928
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
929 r = INREG(FP_V_SYNC_STRT_WID);
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
930 rinfo->VOverPlus = (unsigned short)(r & FP_V_SYNC_STRT_MASK)
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
931 - b + 1;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
932 rinfo->VSyncWidth = (unsigned short)((r & FP_V_SYNC_WID_MASK)
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
933 >> FP_V_SYNC_WID_SHIFT);
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
934
2135
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
935 return 1;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
936 }
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
937
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
938 static void radeon_get_moninfo (struct radeonfb_info *rinfo)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
939 {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
940 unsigned int tmp;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
941
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
942 tmp = INREG(RADEON_BIOS_4_SCRATCH);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
943
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
944 if (rinfo->hasCRTC2) {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
945 /* primary DVI port */
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
946 if (tmp & 0x08)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
947 rinfo->dviDispType = MT_DFP;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
948 else if (tmp & 0x4)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
949 rinfo->dviDispType = MT_LCD;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
950 else if (tmp & 0x200)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
951 rinfo->dviDispType = MT_CRT;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
952 else if (tmp & 0x10)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
953 rinfo->dviDispType = MT_CTV;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
954 else if (tmp & 0x20)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
955 rinfo->dviDispType = MT_STV;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
956
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
957 /* secondary CRT port */
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
958 if (tmp & 0x2)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
959 rinfo->crtDispType = MT_CRT;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
960 else if (tmp & 0x800)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
961 rinfo->crtDispType = MT_DFP;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
962 else if (tmp & 0x400)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
963 rinfo->crtDispType = MT_LCD;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
964 else if (tmp & 0x1000)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
965 rinfo->crtDispType = MT_CTV;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
966 else if (tmp & 0x2000)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
967 rinfo->crtDispType = MT_STV;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
968 } else {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
969 rinfo->dviDispType = MT_NONE;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
970
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
971 tmp = INREG(FP_GEN_CNTL);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
972
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
973 if (tmp & FP_EN_TMDS)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
974 rinfo->crtDispType = MT_DFP;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
975 else
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
976 rinfo->crtDispType = MT_CRT;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
977 }
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
978 }
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
979
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
980 static int radeonfb_pci_register (struct pci_dev *pdev,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
981 const struct pci_device_id *ent)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
982 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
983 struct radeonfb_info *rinfo;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
984 u32 tmp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
985 int i, j;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
986 char *bios_seg = NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
987
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
988 rinfo = kmalloc (sizeof (struct radeonfb_info), GFP_KERNEL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
989 if (!rinfo) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
990 printk ("radeonfb: could not allocate memory\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
991 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
992 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
993
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
994 memset (rinfo, 0, sizeof (struct radeonfb_info));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
995
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
996 rinfo->pdev = pdev;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
997
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
998 /* enable device */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
999 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1000 int err;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1001
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1002 if ((err = pci_enable_device(pdev))) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1003 printk("radeonfb: cannot enable device\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1004 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1005 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1006 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1007 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1008
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1009 /* set base addrs */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1010 rinfo->fb_base_phys = pci_resource_start (pdev, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1011 rinfo->mmio_base_phys = pci_resource_start (pdev, 2);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1012
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1013 /* request the mem regions */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1014 if (!request_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1015 pci_resource_len(pdev, 0), "radeonfb")) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1016 printk ("radeonfb: cannot reserve FB region\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1017 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1018 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1019 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1020
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1021 if (!request_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1022 pci_resource_len(pdev, 2), "radeonfb")) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1023 printk ("radeonfb: cannot reserve MMIO region\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1024 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1025 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1026 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1027 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1028 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1029
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1030 /* map the regions */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1031 rinfo->mmio_base = (u32) ioremap (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1032 RADEON_REGSIZE);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1033 if (!rinfo->mmio_base) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1034 printk ("radeonfb: cannot map MMIO\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1035 release_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1036 pci_resource_len(pdev, 2));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1037 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1038 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1039 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1040 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1041 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1042
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1043 rinfo->chipset = pdev->device;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1044
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1045 /* chipset */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1046 switch (pdev->device) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1047 case PCI_DEVICE_ID_RADEON_QD:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1048 strcpy(rinfo->name, "Radeon QD ");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1049 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1050 case PCI_DEVICE_ID_RADEON_QE:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1051 strcpy(rinfo->name, "Radeon QE ");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1052 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1053 case PCI_DEVICE_ID_RADEON_QF:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1054 strcpy(rinfo->name, "Radeon QF ");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1055 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1056 case PCI_DEVICE_ID_RADEON_QG:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1057 strcpy(rinfo->name, "Radeon QG ");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1058 break;
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
1059 case PCI_DEVICE_ID_RADEON_QY:
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1060 rinfo->hasCRTC2 = 1;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1061 strcpy(rinfo->name, "Radeon VE QY ");
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
1062 break;
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
1063 case PCI_DEVICE_ID_RADEON_QZ:
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1064 rinfo->hasCRTC2 = 1;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1065 strcpy(rinfo->name, "Radeon VE QZ ");
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1066 break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1067 case PCI_DEVICE_ID_RADEON_LY:
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1068 rinfo->hasCRTC2 = 1;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1069 rinfo->isM6 = 1;
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1070 strcpy(rinfo->name, "Radeon M6 LY ");
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1071 break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1072 case PCI_DEVICE_ID_RADEON_LZ:
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1073 rinfo->hasCRTC2 = 1;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1074 rinfo->isM6 = 1;
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1075 strcpy(rinfo->name, "Radeon M6 LZ ");
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1076 break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1077 case PCI_DEVICE_ID_RADEON_LW:
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1078 /* Note: Only difference between VE,M6 and M7 is initialization CRTC2
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1079 registers in dual monitor configuration!!! */
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1080 rinfo->hasCRTC2 = 1;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1081 rinfo->isM7 = 1;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1082 strcpy(rinfo->name, "Radeon M7 LW ");
1912
33afcb62fc64 Radeon VE support
nick
parents: 1911
diff changeset
1083 break;
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1084 case PCI_DEVICE_ID_R200_QL:
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1085 rinfo->hasCRTC2 = 1;
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1086 rinfo->isR200 = 1;
1969
609d4ea3d72b Typo fix
nick
parents: 1967
diff changeset
1087 strcpy(rinfo->name, "Radeon2 8500 QL ");
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1088 break;
3940
db3a8c95bcf7 Added support of Radeon2 8500 AIW
nick
parents: 3555
diff changeset
1089 case PCI_DEVICE_ID_R200_BB:
db3a8c95bcf7 Added support of Radeon2 8500 AIW
nick
parents: 3555
diff changeset
1090 rinfo->hasCRTC2 = 1;
db3a8c95bcf7 Added support of Radeon2 8500 AIW
nick
parents: 3555
diff changeset
1091 rinfo->isR200 = 1;
db3a8c95bcf7 Added support of Radeon2 8500 AIW
nick
parents: 3555
diff changeset
1092 strcpy(rinfo->name, "Radeon2 8500 AIW");
db3a8c95bcf7 Added support of Radeon2 8500 AIW
nick
parents: 3555
diff changeset
1093 break;
1967
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1094 case PCI_DEVICE_ID_RV200_QW:
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1095 rinfo->hasCRTC2 = 1;
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1096 rinfo->isM7 = 1;
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1097 strcpy(rinfo->name, "Radeon2 7500 QW ");
4e3e03effdac Radeon2 support
nick
parents: 1966
diff changeset
1098 break;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1099 default:
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1100 release_mem_region (rinfo->mmio_base_phys,
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1101 pci_resource_len(pdev, 2));
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1102 release_mem_region (rinfo->fb_base_phys,
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1103 pci_resource_len(pdev, 0));
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1104 kfree (rinfo);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1105 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1106 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1107
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1108 /* framebuffer size */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1109 tmp = INREG(CONFIG_MEMSIZE);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1110
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1111 /* mem size is bits [28:0], mask off the rest */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1112 rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1113
8941
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1114 /* according to XFree86 4.2.0, some production M6's return
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1115 0 for 8MB */
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1116 if (rinfo->video_ram == 0 &&
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1117 (pdev->device == PCI_DEVICE_ID_RADEON_LY ||
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1118 pdev->device == PCI_DEVICE_ID_RADEON_LZ))
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1119 {
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1120 rinfo->video_ram = 8192*1024;
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1121 printk("radeonfb: workarounding buggy Radeon M6 (0 vs 8MB memory)\n");
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1122 }
ca2ff7e1b66e M6 bug workaround by Hanno Bock <hanno@gmx.de>
alex
parents: 3940
diff changeset
1123
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1124 /* ram type */
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1125 rinfo->MemCntl = INREG(MEM_SDRAM_MODE_REG);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1126 switch ((MEM_CFG_TYPE & rinfo->MemCntl) >> 30) {
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1127 case 0:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1128 /* SDR SGRAM (2:1) */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1129 strcpy(rinfo->ram_type, "SDR SGRAM");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1130 rinfo->ram.ml = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1131 rinfo->ram.mb = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1132 rinfo->ram.trcd = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1133 rinfo->ram.trp = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1134 rinfo->ram.twr = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1135 rinfo->ram.cl = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1136 rinfo->ram.loop_latency = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1137 rinfo->ram.rloop = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1138
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1139 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1140 case 1:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1141 /* DDR SGRAM */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1142 strcpy(rinfo->ram_type, "DDR SGRAM");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1143 rinfo->ram.ml = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1144 rinfo->ram.mb = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1145 rinfo->ram.trcd = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1146 rinfo->ram.trp = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1147 rinfo->ram.twr = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1148 rinfo->ram.cl = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1149 rinfo->ram.tr2w = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1150 rinfo->ram.loop_latency = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1151 rinfo->ram.rloop = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1152
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1153 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1154 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1155 /* 64-bit SDR SGRAM */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1156 strcpy(rinfo->ram_type, "SDR SGRAM 64");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1157 rinfo->ram.ml = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1158 rinfo->ram.mb = 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1159 rinfo->ram.trcd = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1160 rinfo->ram.trp = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1161 rinfo->ram.twr = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1162 rinfo->ram.cl = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1163 rinfo->ram.tr2w = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1164 rinfo->ram.loop_latency = 17;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1165 rinfo->ram.rloop = 17;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1166
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1167 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1168 }
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1169 /* Bus type */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1170 rinfo->BusCntl = INREG(BUS_CNTL);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1171
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1172 bios_seg = radeon_find_rom(rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1173 radeon_get_pllinfo(rinfo, bios_seg);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1174
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1175 printk("radeonfb: ref_clk=%d, ref_div=%d, xclk=%d\n",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1176 rinfo->pll.ref_clk, rinfo->pll.ref_div, rinfo->pll.xclk);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1177
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1178 RTRACE("radeonfb: probed %s %dk videoram\n", (rinfo->ram_type), (rinfo->video_ram/1024));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1179
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1180 radeon_get_moninfo(rinfo);
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1181
2135
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1182 if((rinfo->dviDispType == MT_DFP || rinfo->dviDispType == MT_LCD ||
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1183 rinfo->crtDispType == MT_DFP))
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1184 if(!radeon_get_dfp_info(rinfo)) goto reg_err;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1185 rinfo->fb_base = (u32) ioremap (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1186 rinfo->video_ram);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1187 if (!rinfo->fb_base) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1188 printk ("radeonfb: cannot map FB\n");
2135
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1189 reg_err:
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1190 iounmap ((void*)rinfo->mmio_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1191 release_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1192 pci_resource_len(pdev, 2));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1193 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1194 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1195 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1196 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1197 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1198
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1199 /* XXX turn off accel for now, blts aren't working right */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1200 noaccel = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1201
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1202 /* set all the vital stuff */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1203 radeon_set_fbinfo (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1204
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1205 /* save current mode regs before we switch into the new one
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1206 * so we can restore this upon __exit
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1207 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1208 radeon_save_state (rinfo, &rinfo->init_state);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1209
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1210 /* init palette */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1211 for (i=0; i<16; i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1212 j = color_table[i];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1213 rinfo->palette[i].red = default_red[j];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1214 rinfo->palette[i].green = default_grn[j];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1215 rinfo->palette[i].blue = default_blu[j];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1216 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1217
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1218 pci_set_drvdata(pdev, rinfo);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1219
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1220 if (register_framebuffer ((struct fb_info *) rinfo) < 0) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1221 printk ("radeonfb: could not register framebuffer\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1222 iounmap ((void*)rinfo->fb_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1223 iounmap ((void*)rinfo->mmio_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1224 release_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1225 pci_resource_len(pdev, 2));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1226 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1227 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1228 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1229 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1230 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1231
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1232 if (!noaccel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1233 /* initialize the engine */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1234 radeon_engine_init (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1235 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1236
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1237 printk ("radeonfb: ATI %s %s %d MB\n",rinfo->name,rinfo->ram_type,
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1238 (rinfo->video_ram/(1024*1024)));
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1239 if(rinfo->hasCRTC2) {
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1240 printk("radeonfb: DVI port has %s monitor connected\n",GET_MON_NAME(rinfo->dviDispType));
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1241 printk("radeonfb: CRT port has %s monitor connected\n",GET_MON_NAME(rinfo->crtDispType));
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1242 }
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1243 else
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1244 printk("radeonfb: CRT port has %s monitor connected\n",GET_MON_NAME(rinfo->crtDispType));
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1245 #ifdef CONFIG_MTRR
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1246 if (mtrr) {
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1247 rinfo->mtrr.vram = mtrr_add(rinfo->fb_base_phys,
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1248 rinfo->video_ram, MTRR_TYPE_WRCOMB, 1);
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1249 rinfo->mtrr.vram_valid = 1;
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1250 /* let there be speed */
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1251 printk("radeonfb: MTRR set to ON\n");
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1252 }
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1253 #endif /* CONFIG_MTRR */
2037
11cae7a32291 Rage theatre detection
nick
parents: 1969
diff changeset
1254 return 0;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1255 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1256
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1257
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1258
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1259 static void __devexit radeonfb_pci_unregister (struct pci_dev *pdev)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1260 {
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1261 struct radeonfb_info *rinfo = pci_get_drvdata(pdev);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1262
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1263 if (!rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1264 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1265
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1266 /* restore original state */
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1267 radeon_write_state (rinfo, &rinfo->init_state);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1268
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1269 unregister_framebuffer ((struct fb_info *) rinfo);
1951
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1270 #ifdef CONFIG_MTRR
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1271 if (rinfo->mtrr.vram_valid)
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1272 mtrr_del(rinfo->mtrr.vram, rinfo->fb_base_phys,
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1273 rinfo->video_ram);
b2b85982fc0e MTRR autoconfigure
nick
parents: 1916
diff changeset
1274 #endif /* CONFIG_MTRR */
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1275 iounmap ((void*)rinfo->mmio_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1276 iounmap ((void*)rinfo->fb_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1277
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1278 release_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1279 pci_resource_len(pdev, 2));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1280 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1281 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1282
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1283 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1284 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1285
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1286
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1287
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1288 static char *radeon_find_rom(struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1289 {
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1290 #if defined(__i386__)
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1291 u32 segstart;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1292 char *rom_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1293 char *rom;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1294 int stage;
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1295 int i,j;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1296 char aty_rom_sig[] = "761295520";
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1297 char *radeon_sig[] = {
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1298 "RG6",
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1299 "RADEON"
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1300 };
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1301
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1302 for(segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1303 stage = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1304
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1305 rom_base = (char *)ioremap(segstart, 0x1000);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1306
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1307 if ((*rom_base == 0x55) && (((*(rom_base + 1)) & 0xff) == 0xaa))
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1308 stage = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1309
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1310
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1311 if (stage != 2) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1312 iounmap(rom_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1313 continue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1314 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1315
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1316 rom = rom_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1317
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1318 for (i = 0; (i < 128 - strlen(aty_rom_sig)) && (stage != 3); i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1319 if (aty_rom_sig[0] == *rom)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1320 if (strncmp(aty_rom_sig, rom,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1321 strlen(aty_rom_sig)) == 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1322 stage = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1323 rom++;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1324 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1325 if (stage != 3) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1326 iounmap(rom_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1327 continue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1328 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1329 rom = rom_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1330
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1331 for (i = 0; (i < 512) && (stage != 4); i++) {
1915
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1332 for(j = 0;j < sizeof(radeon_sig)/sizeof(char *);j++) {
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1333 if (radeon_sig[j][0] == *rom)
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1334 if (strncmp(radeon_sig[j], rom,
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1335 strlen(radeon_sig[j])) == 0) {
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1336 stage = 4;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1337 break;
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1338 }
31fdf7bb1a8e A lot of VE related improvements and code cleanup
nick
parents: 1914
diff changeset
1339 }
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1340 rom++;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1341 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1342 if (stage != 4) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1343 iounmap(rom_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1344 continue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1345 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1346
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1347 return rom_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1348 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1349 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1350 return NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1351 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1352
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1353 #if defined(__powerpc__)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1354 static int radeon_read_OF (struct radeonfb_info *rinfo)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1355 {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1356 struct device_node *dp;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1357 unsigned int *xtal;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1358
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1359 dp = pci_device_to_OF_node(rinfo->pdev);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1360
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1361 xtal = (unsigned int *) get_property(dp, "ATY,RefCLK", 0);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1362
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1363 rinfo->pll.ref_clk = *xtal / 10;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1364
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1365 if (*xtal)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1366 return 1;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1367 else
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1368 return 0;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1369 }
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1370 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1371
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1372 static void radeon_get_pllinfo(struct radeonfb_info *rinfo, char *bios_seg)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1373 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1374 void *bios_header;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1375 void *header_ptr;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1376 u16 bios_header_offset, pll_info_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1377 PLL_BLOCK pll;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1378
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1379 if (bios_seg) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1380 bios_header = bios_seg + 0x48L;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1381 header_ptr = bios_header;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1382
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1383 bios_header_offset = readw(header_ptr);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1384 bios_header = bios_seg + bios_header_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1385 bios_header += 0x30;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1386
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1387 header_ptr = bios_header;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1388 pll_info_offset = readw(header_ptr);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1389 header_ptr = bios_seg + pll_info_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1390
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1391 memcpy_fromio(&pll, header_ptr, 50);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1392
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1393 rinfo->pll.xclk = (u32)pll.XCLK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1394 rinfo->pll.ref_clk = (u32)pll.PCLK_ref_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1395 rinfo->pll.ref_div = (u32)pll.PCLK_ref_divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1396 rinfo->pll.ppll_min = pll.PCLK_min_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1397 rinfo->pll.ppll_max = pll.PCLK_max_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1398 } else {
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1399 #if defined(__powerpc__)
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1400 if (radeon_read_OF(rinfo)) {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1401 unsigned int tmp, Nx, M, ref_div, xclk;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1402
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1403 tmp = INPLL(M_SPLL_REF_FB_DIV);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1404 ref_div = INPLL(PPLL_REF_DIV) & 0x3ff;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1405
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1406 Nx = (tmp & 0xff00) >> 8;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1407 M = (tmp & 0xff);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1408 xclk = ((((2 * Nx * rinfo->pll.ref_clk) + (M)) /
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1409 (2 * M)));
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1410
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1411 rinfo->pll.xclk = xclk;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1412 rinfo->pll.ref_div = ref_div;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1413 rinfo->pll.ppll_min = 12000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1414 rinfo->pll.ppll_max = 35000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1415
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1416 printk("radeonfb: ref_clk=%d, ref_div=%d, xclk=%d from OF\n",
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1417 rinfo->pll.ref_clk, rinfo->pll.ref_div, rinfo->pll.xclk);
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1418
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1419 return;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1420 }
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1421 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1422 /* no BIOS or BIOS not found, use defaults */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1423
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1424 switch (rinfo->chipset) {
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1425 case PCI_DEVICE_ID_RV200_QW:
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1426 rinfo->pll.ppll_max = 35000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1427 rinfo->pll.ppll_min = 12000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1428 rinfo->pll.xclk = 23000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1429 rinfo->pll.ref_div = 12;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1430 rinfo->pll.ref_clk = 2700;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1431 break;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1432 case PCI_DEVICE_ID_R200_QL:
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1433 rinfo->pll.ppll_max = 35000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1434 rinfo->pll.ppll_min = 12000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1435 rinfo->pll.xclk = 27500;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1436 rinfo->pll.ref_div = 12;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1437 rinfo->pll.ref_clk = 2700;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1438 break;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1439 case PCI_DEVICE_ID_RADEON_QD:
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1440 case PCI_DEVICE_ID_RADEON_QE:
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1441 case PCI_DEVICE_ID_RADEON_QF:
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1442 case PCI_DEVICE_ID_RADEON_QG:
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1443 default:
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1444 rinfo->pll.ppll_max = 35000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1445 rinfo->pll.ppll_min = 12000;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1446 rinfo->pll.xclk = 16600;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1447 rinfo->pll.ref_div = 67;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1448 rinfo->pll.ref_clk = 2700;
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
1449 };
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1450 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1451 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1452
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1453 static void radeon_init_common_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1454 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1455 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1456 RTRACE("radeonfb: radeon_init_common_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1457 save->ovr_clr = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1458 save->ovr_wid_left_right= 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1459 save->ovr_wid_top_bottom= 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1460 save->ov0_scale_cntl = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1461 save->mpp_tb_config = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1462 save->mpp_gp_config = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1463 save->subpic_cntl = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1464 save->i2c_cntl_1 = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1465 save->rbbm_soft_reset = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1466 save->cap0_trig_cntl = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1467 save->cap1_trig_cntl = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1468 save->bus_cntl = rinfo->BusCntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1469 /*
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1470 * If bursts are enabled, turn on discards
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1471 * Radeon doesn't have write bursts
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1472 */
2160
81f16b270b8b Enable discards - now it works
nick
parents: 2142
diff changeset
1473 if (save->bus_cntl & (BUS_READ_BURST))
81f16b270b8b Enable discards - now it works
nick
parents: 2142
diff changeset
1474 save->bus_cntl |= BUS_RD_DISCARD_EN;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1475 }
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1476
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1477 static int radeon_init_crtc_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1478 struct radeon_regs *save,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1479 struct fb_var_screeninfo *mode)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1480 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1481 int hTotal, vTotal, hSyncStart, hSyncEnd,
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1482 vSyncStart, vSyncEnd, cSync;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1483 u8 hsync_adj_tab[] = {0, 0x12, 9, 9, 6, 5};
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1484 u8 hsync_fudge_fp[] = { 2, 2, 0, 0, 5, 5 };
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1485 u32 sync;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1486 int format = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1487 int hsync_start, hsync_fudge, bytpp, hsync_wid, vsync_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1488 int prim_mon;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1489
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1490 prim_mon = PRIMARY_MONITOR(rinfo);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1491
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1492 rinfo->xres = mode->xres;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1493 rinfo->yres = mode->yres;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1494 rinfo->pixclock = mode->pixclock;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1495
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1496 hSyncStart = mode->xres + mode->right_margin;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1497 hSyncEnd = hSyncStart + mode->hsync_len;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1498 hTotal = hSyncEnd + mode->left_margin;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1499
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1500 vSyncStart = mode->yres + mode->lower_margin;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1501 vSyncEnd = vSyncStart + mode->vsync_len;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1502 vTotal = vSyncEnd + mode->upper_margin;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1503
2135
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1504 if(((prim_mon == MT_DFP) || (prim_mon == MT_LCD)))
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1505 {
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1506 if(rinfo->PanelXRes < mode->xres)
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1507 rinfo->xres = mode->xres = rinfo->PanelXRes;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1508 if(rinfo->PanelYRes < mode->yres)
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1509 rinfo->yres = mode->yres = rinfo->PanelYRes;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1510 hTotal = mode->xres + rinfo->HBlank + mode->left_margin;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1511 hSyncStart = mode->xres + rinfo->HOverPlus + mode->right_margin;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1512 hSyncEnd = hSyncStart + rinfo->HSyncWidth + mode->hsync_len;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1513 vTotal = mode->yres + rinfo->VBlank + mode->upper_margin;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1514 vSyncStart = mode->yres + rinfo->VOverPlus + mode->lower_margin;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1515 vSyncEnd = vSyncStart + rinfo->VSyncWidth + mode->vsync_len;
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1516 }
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1517
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1518 sync = mode->sync;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1519
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1520 RTRACE("hStart = %d, hEnd = %d, hTotal = %d\n",
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1521 hSyncStart, hSyncEnd, hTotal);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1522 RTRACE("vStart = %d, vEnd = %d, vTotal = %d\n",
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1523 vSyncStart, vSyncEnd, vTotal);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1524
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1525 hsync_wid = (hSyncEnd - hSyncStart) / 8;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1526 vsync_wid = vSyncEnd - vSyncStart;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1527 if (hsync_wid == 0)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1528 hsync_wid = 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1529 else if (hsync_wid > 0x3f) /* max */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1530 hsync_wid = 0x3f;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1531 vsync_wid = mode->vsync_len;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1532 if (vsync_wid == 0)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1533 vsync_wid = 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1534 else if (vsync_wid > 0x1f) /* max */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1535 vsync_wid = 0x1f;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1536
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1537 cSync = mode->sync & FB_SYNC_COMP_HIGH_ACT ? (1 << 4) : 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1538
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1539 switch (mode->bits_per_pixel) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1540 case 8:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1541 format = DST_8BPP;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1542 bytpp = 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1543 break;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1544 case 16:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1545 format = DST_16BPP;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1546 bytpp = 2;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1547 break;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1548 case 24:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1549 format = DST_24BPP;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1550 bytpp = 3;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1551 break;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1552 case 32:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1553 format = DST_32BPP;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1554 bytpp = 4;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1555 break;
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1556 default:
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1557 printk("radeonfb: Unsupported pixel depth (%d)\n", mode->bits_per_pixel);
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1558 return 0;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1559 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1560
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1561 if ((prim_mon == MT_DFP) || (prim_mon == MT_LCD))
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1562 hsync_fudge = hsync_fudge_fp[format-1];
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1563 else
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1564 hsync_fudge = hsync_adj_tab[format-1];
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1565
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1566 hsync_start = hSyncStart - 8 + hsync_fudge;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1567 save->crtc_gen_cntl = (CRTC_EXT_DISP_EN
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1568 | CRTC_EN
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1569 | (format << 8)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1570 /* | CRTC_DBL_SCAN_EN*/);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1571
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1572 if((prim_mon == MT_DFP) || (prim_mon == MT_LCD)) {
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1573 save->crtc_ext_cntl = VGA_ATI_LINEAR |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1574 XCRT_CNT_EN;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1575 save->crtc_gen_cntl &= ~(CRTC_DBL_SCAN_EN |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1576 CRTC_INTERLACE_EN);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1577 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1578 else
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1579 save->crtc_ext_cntl = VGA_ATI_LINEAR |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1580 XCRT_CNT_EN |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1581 CRTC_CRT_ON;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1582
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1583 save->dac_cntl = (DAC_MASK_ALL
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1584 | DAC_VGA_ADR_EN
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1585 | DAC_8BIT_EN);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1586
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1587 save->crtc_h_total_disp = ((((hTotal / 8) - 1) & 0x3ff) |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1588 ((((mode->xres / 8) - 1) & 0x1ff) << 16));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1589
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1590 save->crtc_v_total_disp = ((vTotal - 1) & 0xffff) |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1591 ((mode->yres - 1) << 16);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1592
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1593 save->crtc_h_sync_strt_wid = ((hsync_start & 0x1fff)
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1594 | (hsync_wid << 16)
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1595 | (mode->sync & FB_SYNC_HOR_HIGH_ACT ? 0
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1596 : CRTC_H_SYNC_POL));
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1597
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1598 save->crtc_v_sync_strt_wid = (((vSyncStart - 1) & 0xfff)
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1599 | (vsync_wid << 16)
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1600 | (mode->sync & FB_SYNC_VERT_HIGH_ACT ? 0
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1601 : CRTC_V_SYNC_POL));
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1602
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1603 save->crtc_pitch = ((mode->xres * bytpp) +
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1604 ((mode->bits_per_pixel) - 1)) /
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1605 (mode->bits_per_pixel);
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1606 save->crtc_pitch |= save->crtc_pitch<<16;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1607
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1608 #if defined(__BIG_ENDIAN)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1609 save->surface_cntl = SURF_TRANSLATION_DIS;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1610 switch (mode->bits_per_pixel) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1611 case 16:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1612 save->surface_cntl |= NONSURF_AP0_SWP_16BPP;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1613 break;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1614 case 24:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1615 case 32:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1616 save->surface_cntl |= NONSURF_AP0_SWP_32BPP;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1617 break;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1618 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1619 #endif
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1620
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1621 rinfo->pitch = ((mode->xres * ((mode->bits_per_pixel + 1) / 8) + 0x3f)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1622 & ~(0x3f)) / 64;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1623
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1624 RTRACE("h_total_disp = 0x%x\t hsync_strt_wid = 0x%x\n",
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1625 save->crtc_h_total_disp, save->crtc_h_sync_strt_wid);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1626 RTRACE("v_total_disp = 0x%x\t vsync_strt_wid = 0x%x\n",
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1627 save->crtc_v_total_disp, save->crtc_v_sync_strt_wid);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1628
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1629 save->xres = mode->xres;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1630 save->yres = mode->yres;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1631
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1632 save->crtc_offset = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1633 save->crtc_offset_cntl = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1634
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1635 rinfo->bpp = mode->bits_per_pixel;
2133
96d1926373a1 Fixed incorrect return value
nick
parents: 2132
diff changeset
1636 return 1;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1637 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1638
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1639 static int radeon_init_crtc2_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1640 struct radeon_regs *save,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1641 struct fb_var_screeninfo *mode)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1642 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1643 int format;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1644 int hsync_start;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1645 int hsync_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1646 int hsync_fudge;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1647 int vsync_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1648 int bytpp;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1649 int hsync_fudge_default[] = { 0x00, 0x12, 0x09, 0x09, 0x06, 0x05 };
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1650 int hTotal, vTotal, hSyncStart, hSyncEnd;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1651 int vSyncStart, vSyncEnd;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1652 RTRACE("radeonfb: radeon_init_crtc2_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1653
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1654 switch (mode->bits_per_pixel) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1655 case 8: format = 2; bytpp = 1; break;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1656 case 16: format = 4; bytpp = 2; break; /* 565 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1657 case 24: format = 5; bytpp = 3; break; /* RGB */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1658 case 32: format = 6; bytpp = 4; break; /* xRGB */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1659 default:
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1660 printk("radeonfb: Unsupported pixel depth (%d)\n", mode->bits_per_pixel);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1661 return 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1662 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1663
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1664 hsync_fudge = hsync_fudge_default[format-1];
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1665
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1666 save->crtc2_gen_cntl = (CRTC2_EN
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1667 | CRTC2_CRT2_ON
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1668 | (format << 8)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1669 /*| CRTC2_DBL_SCAN_EN*/);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1670
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1671 if(!rinfo->isM7)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1672 save->dac2_cntl = rinfo->init_state.dac2_cntl
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1673 /*| DAC2_DAC2_CLK_SEL*/
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1674 | DAC2_DAC_CLK_SEL;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1675 else
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1676 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1677 save->disp_output_cntl =
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1678 ((rinfo->init_state.disp_output_cntl &
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1679 (u32)~DISP_DAC_SOURCE_MASK)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1680 | DISP_DAC_SOURCE_CRTC2);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1681 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1682
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1683 hSyncStart = mode->xres + mode->right_margin;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1684 hSyncEnd = hSyncStart + mode->hsync_len;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1685 hTotal = hSyncEnd + mode->left_margin;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1686
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1687 vSyncStart = mode->yres + mode->lower_margin;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1688 vSyncEnd = vSyncStart + mode->vsync_len;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1689 vTotal = vSyncEnd + mode->upper_margin;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1690
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1691 save->crtc2_h_total_disp = ((((hTotal / 8) - 1) & 0x3ff)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1692 | ((((mode->xres / 8) - 1) & 0x1ff) << 16));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1693
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1694 hsync_wid = (hSyncEnd - hSyncStart) / 8;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1695 if (!hsync_wid) hsync_wid = 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1696 if (hsync_wid > 0x3f) hsync_wid = 0x3f;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1697 hsync_start = hSyncStart - 8 + hsync_fudge;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1698
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1699 save->crtc2_h_sync_strt_wid = ((hsync_start & 0x1fff)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1700 | (hsync_wid << 16)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1701 | ((mode->sync & FB_SYNC_HOR_HIGH_ACT)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1702 ? 0
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1703 : CRTC_H_SYNC_POL));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1704
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1705 /* This works for double scan mode. */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1706 save->crtc2_v_total_disp = (((vTotal - 1) & 0xffff)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1707 | ((mode->yres - 1) << 16));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1708
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1709 vsync_wid = vSyncEnd - vSyncStart;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1710 if (!vsync_wid) vsync_wid = 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1711 if (vsync_wid > 0x1f) vsync_wid = 0x1f;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1712
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1713 save->crtc2_v_sync_strt_wid = (((vSyncStart - 1) & 0xfff)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1714 | (vsync_wid << 16)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1715 | ((mode->sync & FB_SYNC_VERT_HIGH_ACT)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1716 ? 0
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1717 : CRTC2_V_SYNC_POL));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1718
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1719 save->crtc2_offset = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1720 save->crtc2_offset_cntl = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1721
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1722 save->crtc2_pitch = ((mode->xres * bytpp) +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1723 ((mode->bits_per_pixel) -1)) /
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1724 (mode->bits_per_pixel);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1725 save->crtc2_pitch |= save->crtc2_pitch << 16;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1726
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1727 RTRACE("radeonfb: radeon_init_crtc2_regs returns SUCCESS\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1728 return 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1729 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1730
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1731 static void radeon_init_fp_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1732 struct radeon_regs *save,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1733 struct fb_var_screeninfo *mode)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1734 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1735 float Hratio, Vratio;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1736 int prim_mon;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1737 RTRACE("radeonfb: radeon_init_fp_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1738 if(rinfo->PanelXRes == 0 || rinfo->PanelYRes == 0)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1739 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1740 Hratio = 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1741 Vratio = 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1742 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1743 else
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1744 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1745 if (mode->xres > rinfo->PanelXRes) mode->xres = rinfo->PanelXRes;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1746 if (mode->yres > rinfo->PanelYRes) mode->yres = rinfo->PanelYRes;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1747
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1748 Hratio = (float)mode->xres/(float)rinfo->PanelXRes;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1749 Vratio = (float)mode->yres/(float)rinfo->PanelYRes;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1750 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1751
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1752 if (Hratio == 1.0)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1753 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1754 save->fp_horz_stretch = rinfo->init_state.fp_horz_stretch;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1755 save->fp_horz_stretch &= ~(HORZ_STRETCH_BLEND |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1756 HORZ_STRETCH_ENABLE);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1757 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1758 else
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1759 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1760 save->fp_horz_stretch =
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1761 ((((unsigned long)(Hratio * HORZ_STRETCH_RATIO_MAX +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1762 0.5)) & HORZ_STRETCH_RATIO_MASK)) |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1763 (rinfo->init_state.fp_horz_stretch & (HORZ_PANEL_SIZE |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1764 HORZ_FP_LOOP_STRETCH |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1765 HORZ_AUTO_RATIO_INC));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1766 save->fp_horz_stretch |= (HORZ_STRETCH_BLEND |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1767 HORZ_STRETCH_ENABLE);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1768 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1769 save->fp_horz_stretch &= ~HORZ_AUTO_RATIO;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1770
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1771 if (Vratio == 1.0)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1772 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1773 save->fp_vert_stretch = rinfo->init_state.fp_vert_stretch;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1774 save->fp_vert_stretch &= ~(VERT_STRETCH_ENABLE|
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1775 VERT_STRETCH_BLEND);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1776 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1777 else
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1778 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1779 save->fp_vert_stretch =
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1780 (((((unsigned long)(Vratio * VERT_STRETCH_RATIO_MAX +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1781 0.5)) & VERT_STRETCH_RATIO_MASK)) |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1782 (rinfo->init_state.fp_vert_stretch & (VERT_PANEL_SIZE |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1783 VERT_STRETCH_RESERVED)));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1784 save->fp_vert_stretch |= (VERT_STRETCH_ENABLE |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1785 VERT_STRETCH_BLEND);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1786 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1787 save->fp_vert_stretch &= ~VERT_AUTO_RATIO_EN;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1788
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1789 save->fp_gen_cntl = (rinfo->init_state.fp_gen_cntl & (u32)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1790 ~(FP_SEL_CRTC2 |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1791 FP_RMX_HVSYNC_CONTROL_EN |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1792 FP_DFP_SYNC_SEL |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1793 FP_CRT_SYNC_SEL |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1794 FP_CRTC_LOCK_8DOT |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1795 FP_USE_SHADOW_EN |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1796 FP_CRTC_USE_SHADOW_VEND |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1797 FP_CRT_SYNC_ALT));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1798 save->fp_gen_cntl |= (FP_CRTC_DONT_SHADOW_VPAR |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1799 FP_CRTC_DONT_SHADOW_HEND );
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1800
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1801 save->lvds_gen_cntl = rinfo->init_state.lvds_gen_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1802 save->lvds_pll_cntl = rinfo->init_state.lvds_pll_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1803 save->tmds_crc = rinfo->init_state.tmds_crc;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1804
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1805 /* Disable CRT output by disabling CRT output for DFP*/
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1806 save->crtc_ext_cntl &= ~CRTC_CRT_ON;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1807 prim_mon = PRIMARY_MONITOR(rinfo);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1808 if(prim_mon == MT_LCD)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1809 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1810 save->lvds_gen_cntl |= (LVDS_ON | LVDS_BLON);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1811 save->fp_gen_cntl &= ~(FP_FPON | FP_TMDS_EN);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1812 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1813 else if(prim_mon == MT_DFP)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1814 save->fp_gen_cntl |= (FP_FPON | FP_TMDS_EN);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1815
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1816 save->fp_crtc_h_total_disp = rinfo->init_state.fp_crtc_h_total_disp;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1817 save->fp_crtc_v_total_disp = rinfo->init_state.fp_crtc_v_total_disp;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1818 save->fp_h_sync_strt_wid = rinfo->init_state.fp_h_sync_strt_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1819 save->fp_v_sync_strt_wid = rinfo->init_state.fp_v_sync_strt_wid;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1820 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1821
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1822 static void radeon_init_pll_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1823 struct radeon_regs *save,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1824 struct fb_var_screeninfo *mode)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1825 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1826 u32 dot_clock = 1000000000 / mode->pixclock;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1827 u32 freq = dot_clock / 10; /* x 100 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1828 struct {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1829 int divider;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1830 int bitvalue;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1831 } *post_div, post_divs[] = {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1832 { 1, 0 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1833 { 2, 1 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1834 { 4, 2 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1835 { 8, 3 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1836 { 3, 4 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1837 { 16, 5 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1838 { 6, 6 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1839 { 12, 7 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1840 { 0, 0 },
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1841 };
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1842 if (freq > rinfo->pll.ppll_max) freq = rinfo->pll.ppll_max;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1843 if (freq*12 < rinfo->pll.ppll_min) freq = rinfo->pll.ppll_min / 12;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1844
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1845 for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1846 rinfo->pll_output_freq = post_div->divider * freq;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1847 if (rinfo->pll_output_freq >= rinfo->pll.ppll_min &&
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1848 rinfo->pll_output_freq <= rinfo->pll.ppll_max) break;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1849 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1850
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1851 rinfo->post_div = post_div->divider;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1852 rinfo->fb_div = round_div(rinfo->pll.ref_div*rinfo->pll_output_freq,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1853 rinfo->pll.ref_clk);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1854 save->ppll_ref_div = rinfo->pll.ref_div;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1855 save->ppll_div_3 = rinfo->fb_div | (post_div->bitvalue << 16);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1856 save->htotal_cntl = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1857
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1858 RTRACE("post div = 0x%x\n", rinfo->post_div);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1859 RTRACE("fb_div = 0x%x\n", rinfo->fb_div);
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
1860 RTRACE("ppll_div_3 = 0x%x\n", save->ppll_div_3);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1861 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1862
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1863 static void radeon_init_pll2_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1864 struct radeon_regs *save,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1865 struct fb_var_screeninfo *mode)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1866 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1867 u32 dot_clock = 1000000000 / mode->pixclock;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1868 u32 freq = dot_clock * 100;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1869 struct {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1870 int divider;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1871 int bitvalue;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1872 } *post_div,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1873 post_divs[] = {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1874 /* From RAGE 128 VR/RAGE 128 GL Register
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1875 Reference Manual (Technical Reference
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1876 Manual P/N RRG-G04100-C Rev. 0.04), page
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1877 3-17 (PLL_DIV_[3:0]). */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1878 { 1, 0 }, /* VCLK_SRC */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1879 { 2, 1 }, /* VCLK_SRC/2 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1880 { 4, 2 }, /* VCLK_SRC/4 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1881 { 8, 3 }, /* VCLK_SRC/8 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1882 { 3, 4 }, /* VCLK_SRC/3 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1883 { 16, 5 }, /* VCLK_SRC/16 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1884 { 6, 6 }, /* VCLK_SRC/6 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1885 { 12, 7 }, /* VCLK_SRC/12 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1886 { 0, 0 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1887 };
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1888 RTRACE("radeonfb: radeon_init_pll2_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1889
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1890 if (freq > rinfo->pll.ppll_max) freq = rinfo->pll.ppll_max;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1891 if (freq*12 < rinfo->pll.ppll_min) freq = rinfo->pll.ppll_min/12;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1892
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1893 for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1894 save->pll_output_freq_2 = post_div->divider * freq;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1895 if (save->pll_output_freq_2 >= rinfo->pll.ppll_min
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1896 && save->pll_output_freq_2 <= rinfo->pll.ppll_max) break;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1897 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1898
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1899 save->dot_clock_freq_2 = freq;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1900 save->feedback_div_2 = round_div(rinfo->pll.ref_div
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1901 * save->pll_output_freq_2,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1902 rinfo->pll.ref_clk);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1903 save->post_div_2 = post_div->divider;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1904
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1905 save->p2pll_ref_div = rinfo->pll.ref_div;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1906 save->p2pll_div_0 = (save->feedback_div_2 | (post_div->bitvalue<<16));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1907 save->htotal_cntl2 = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1908 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1909
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1910 static int radeon_init_dda_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1911 struct radeon_regs *save,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1912 struct fb_var_screeninfo *mode)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1913 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1914 int xclk_freq, vclk_freq, xclk_per_trans, xclk_per_trans_precise;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1915 int useable_precision, roff, ron;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1916 int min_bits;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1917 const int DispFifoWidth=128,DispFifoDepth=32;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1918 /* DDA */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1919 vclk_freq = round_div(rinfo->pll.ref_clk * rinfo->fb_div,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1920 rinfo->pll.ref_div * rinfo->post_div);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1921 xclk_freq = rinfo->pll.xclk;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1922
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1923 xclk_per_trans = round_div(xclk_freq * DispFifoWidth,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1924 vclk_freq * mode->bits_per_pixel);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1925
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1926 min_bits = min_bits_req(xclk_per_trans);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1927 useable_precision = min_bits + 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1928
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1929 xclk_per_trans_precise = round_div((xclk_freq * DispFifoWidth)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1930 << (11 - useable_precision),
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1931 vclk_freq * mode->bits_per_pixel);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1932
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1933 ron = (4 * rinfo->ram.mb +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1934 3 * _max(rinfo->ram.trcd - 2, 0) +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1935 2 * rinfo->ram.trp +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1936 rinfo->ram.twr +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1937 rinfo->ram.cl +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1938 rinfo->ram.tr2w +
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1939 xclk_per_trans) << (11 - useable_precision);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1940 roff = xclk_per_trans_precise * (DispFifoDepth - 4);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1941
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1942 RTRACE("ron = %d, roff = %d\n", ron, roff);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1943 RTRACE("vclk_freq = %d, per = %d\n", vclk_freq, xclk_per_trans_precise);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1944
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1945 if ((ron + rinfo->ram.rloop) >= roff) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1946 printk("radeonfb: error ron out of range\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1947 return -1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1948 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1949
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1950 save->dda_config = (xclk_per_trans_precise |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1951 (useable_precision << 16) |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1952 (rinfo->ram.rloop << 20));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1953 save->dda_on_off = (ron << 16) | roff;
2134
27bfb445ca85 Fully enabled new logic
nick
parents: 2133
diff changeset
1954 return 1;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1955 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1956
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1957 /*
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1958 static void radeon_init_palette(struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1959 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1960 save->palette_valid = 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1961 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1962 */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1963
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1964 static int radeon_init_mode(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1965 struct radeon_regs *save,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1966 struct fb_var_screeninfo *mode)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1967 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1968 int prim_mon;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1969 RTRACE("radeonfb: radeon_init_mode is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1970 if(DUAL_MONITOR(rinfo))
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1971 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1972 if (!radeon_init_crtc2_regs(rinfo, save, mode))
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1973 return 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1974 radeon_init_pll2_regs(rinfo, save, mode);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1975 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1976 radeon_init_common_regs(rinfo, save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1977 if(!radeon_init_crtc_regs(rinfo, save, mode))
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1978 return 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1979 if(mode->pixclock)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1980 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1981 radeon_init_pll_regs(rinfo, save, mode);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1982 if (!radeon_init_dda_regs(rinfo, save, mode))
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1983 return 0;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1984 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1985 else
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1986 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1987 save->ppll_ref_div = rinfo->init_state.ppll_ref_div;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1988 save->ppll_div_3 = rinfo->init_state.ppll_div_3;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1989 save->htotal_cntl = rinfo->init_state.htotal_cntl;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1990 save->dda_config = rinfo->init_state.dda_config;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1991 save->dda_on_off = rinfo->init_state.dda_on_off;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1992 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1993 /* radeon_init_palete here */
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1994 prim_mon = PRIMARY_MONITOR(rinfo);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1995 if (((prim_mon == MT_DFP) || (prim_mon == MT_LCD)))
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1996 {
2135
fcf5bd49c68f Better DFP support
nick
parents: 2134
diff changeset
1997 radeon_init_fp_regs(rinfo, save, mode);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1998 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
1999
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2000 RTRACE("radeonfb: radeon_init_mode returns SUCCESS\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2001 return 1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2002 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2003
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2004 static void radeon_engine_init (struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2005 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2006 u32 temp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2007
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2008 /* disable 3D engine */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2009 OUTREG(RB3D_CNTL, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2010
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2011 radeon_engine_reset ();
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2012
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2013 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2014 OUTREG(DSTCACHE_MODE, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2015
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2016 /* XXX */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2017 rinfo->pitch = ((rinfo->xres * (rinfo->depth / 8) + 0x3f)) >> 6;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2018
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2019 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2020 temp = INREG(DEFAULT_PITCH_OFFSET);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2021 OUTREG(DEFAULT_PITCH_OFFSET, ((temp & 0xc0000000) |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2022 (rinfo->pitch << 0x16)));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2023
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2024 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2025 OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2026
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2027 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2028 OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2029 DEFAULT_SC_BOTTOM_MAX));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2030
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2031 temp = radeon_get_dstbpp(rinfo->depth);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2032 rinfo->dp_gui_master_cntl = ((temp << 8) | GMC_CLR_CMP_CNTL_DIS);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2033 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2034 OUTREG(DP_GUI_MASTER_CNTL, (rinfo->dp_gui_master_cntl |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2035 GMC_BRUSH_SOLID_COLOR |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2036 GMC_SRC_DATATYPE_COLOR));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2037
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2038 radeon_fifo_wait (7);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2039
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2040 /* clear line drawing regs */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2041 OUTREG(DST_LINE_START, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2042 OUTREG(DST_LINE_END, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2043
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2044 /* set brush color regs */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2045 OUTREG(DP_BRUSH_FRGD_CLR, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2046 OUTREG(DP_BRUSH_BKGD_CLR, 0x00000000);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2047
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2048 /* set source color regs */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2049 OUTREG(DP_SRC_FRGD_CLR, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2050 OUTREG(DP_SRC_BKGD_CLR, 0x00000000);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2051
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2052 /* default write mask */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2053 OUTREG(DP_WRITE_MSK, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2054
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2055 radeon_engine_idle ();
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2056 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2057
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2058
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2059
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2060 static int __devinit radeon_set_fbinfo (struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2061 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2062 struct fb_info *info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2063
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2064 info = &rinfo->info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2065
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2066 strcpy (info->modename, rinfo->name);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2067 info->node = -1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2068 info->flags = FBINFO_FLAG_DEFAULT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2069 info->fbops = &radeon_fb_ops;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2070 info->display_fg = NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2071 strncpy (info->fontname, fontname, sizeof (info->fontname));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2072 info->fontname[sizeof (info->fontname) - 1] = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2073 info->changevar = NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2074 info->switch_con = radeonfb_switch;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2075 info->updatevar = radeonfb_updatevar;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2076 info->blank = radeonfb_blank;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2077
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2078 if (radeon_init_disp (rinfo) < 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2079 return -1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2080
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2081 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2082 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2083
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2084
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2085
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2086 static int __devinit radeon_init_disp (struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2087 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2088 struct fb_info *info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2089 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2090
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2091 info = &rinfo->info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2092 disp = &rinfo->disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2093
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2094 disp->var = radeonfb_default_var;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2095 info->disp = disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2096
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2097 radeon_set_dispsw (rinfo, disp);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2098
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2099 if (noaccel)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2100 disp->scrollmode = SCROLL_YREDRAW;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2101 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2102 disp->scrollmode = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2103
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2104 rinfo->currcon_display = disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2105
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2106 if ((radeon_init_disp_var (rinfo)) < 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2107 return -1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2108
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2109 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2110 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2111
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2112
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2113
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2114 static int radeon_init_disp_var (struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2115 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2116 #ifndef MODULE
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2117 if (mode_option)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2118 fb_find_mode (&rinfo->disp.var, &rinfo->info, mode_option,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2119 NULL, 0, NULL, 8);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2120 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2121 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2122 fb_find_mode (&rinfo->disp.var, &rinfo->info, "640x480-8@60",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2123 NULL, 0, NULL, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2124
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2125 if (noaccel)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2126 rinfo->disp.var.accel_flags &= ~FB_ACCELF_TEXT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2127 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2128 rinfo->disp.var.accel_flags |= FB_ACCELF_TEXT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2129
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2130 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2131 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2132
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2133
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2134 static void radeon_set_dispsw (struct radeonfb_info *rinfo, struct display *disp)
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2135 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2136 int accel;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2137
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2138 accel = disp->var.accel_flags & FB_ACCELF_TEXT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2139
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2140 disp->dispsw_data = NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2141
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2142 disp->screen_base = (char*)rinfo->fb_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2143 disp->type = FB_TYPE_PACKED_PIXELS;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2144 disp->type_aux = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2145 disp->ypanstep = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2146 disp->ywrapstep = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2147 disp->can_soft_blank = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2148 disp->inverse = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2149
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2150 rinfo->depth = disp->var.bits_per_pixel;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2151 switch (disp->var.bits_per_pixel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2152 #ifdef FBCON_HAS_CFB8
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2153 case 8:
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2154 disp->dispsw = &fbcon_cfb8;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2155 disp->visual = FB_VISUAL_PSEUDOCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2156 disp->line_length = disp->var.xres_virtual;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2157 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2158 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2159 #ifdef FBCON_HAS_CFB16
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2160 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2161 disp->dispsw = &fbcon_cfb16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2162 disp->dispsw_data = &rinfo->con_cmap.cfb16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2163 disp->visual = FB_VISUAL_DIRECTCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2164 disp->line_length = disp->var.xres_virtual * 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2165 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2166 #endif
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
2167 #ifdef FBCON_HAS_CFB24
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2168 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2169 disp->dispsw = &fbcon_cfb24;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2170 disp->dispsw_data = &rinfo->con_cmap.cfb24;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2171 disp->visual = FB_VISUAL_DIRECTCOLOR;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2172 disp->line_length = disp->var.xres_virtual * 4;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2173 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2174 #endif
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2175 #ifdef FBCON_HAS_CFB32
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2176 case 32:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2177 disp->dispsw = &fbcon_cfb32;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2178 disp->dispsw_data = &rinfo->con_cmap.cfb32;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2179 disp->visual = FB_VISUAL_DIRECTCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2180 disp->line_length = disp->var.xres_virtual * 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2181 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2182 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2183 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2184 printk ("radeonfb: setting fbcon_dummy renderer\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2185 disp->dispsw = &fbcon_dummy;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2186 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2187
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2188 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2189 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2190
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2191
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2192
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2193 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2194 * fb ops
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2195 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2196
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2197 static int radeonfb_get_fix (struct fb_fix_screeninfo *fix, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2198 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2199 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2200 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2201 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2202
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2203 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2204
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2205 memset (fix, 0, sizeof (struct fb_fix_screeninfo));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2206 strcpy (fix->id, rinfo->name);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2207
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2208 fix->smem_start = rinfo->fb_base_phys;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2209 fix->smem_len = rinfo->video_ram;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2210
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2211 fix->type = disp->type;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2212 fix->type_aux = disp->type_aux;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2213 fix->visual = disp->visual;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2214
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2215 fix->xpanstep = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2216 fix->ypanstep = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2217 fix->ywrapstep = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2218
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2219 fix->line_length = disp->line_length;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2220
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2221 fix->mmio_start = rinfo->mmio_base_phys;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2222 fix->mmio_len = RADEON_REGSIZE;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2223 if (noaccel)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2224 fix->accel = FB_ACCEL_NONE;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2225 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2226 fix->accel = 40; /* XXX */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2227
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2228 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2229 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2230
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2231
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2232
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2233 static int radeonfb_get_var (struct fb_var_screeninfo *var, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2234 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2235 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2236 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2237
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2238 *var = (con < 0) ? rinfo->disp.var : fb_display[con].var;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2239
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2240 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2241 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2242
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2243
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2244
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2245 static int radeonfb_set_var (struct fb_var_screeninfo *var, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2246 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2247 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2248 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2249 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2250 struct fb_var_screeninfo v;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2251 int nom, den, accel, err;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2252 unsigned chgvar = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2253
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2254 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2255
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2256 accel = var->accel_flags & FB_ACCELF_TEXT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2257
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2258 if (con >= 0) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2259 chgvar = ((disp->var.xres != var->xres) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2260 (disp->var.yres != var->yres) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2261 (disp->var.xres_virtual != var->xres_virtual) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2262 (disp->var.yres_virtual != var->yres_virtual) ||
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2263 (disp->var.bits_per_pixel != var->bits_per_pixel) ||
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2264 memcmp (&disp->var.red, &var->red, sizeof (var->red)) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2265 memcmp (&disp->var.green, &var->green, sizeof (var->green)) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2266 memcmp (&disp->var.blue, &var->blue, sizeof (var->blue)));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2267 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2268
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2269 memcpy (&v, var, sizeof (v));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2270
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2271 switch (v.bits_per_pixel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2272 #ifdef FBCON_HAS_CFB8
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2273 case 8:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2274 nom = den = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2275 disp->line_length = v.xres_virtual;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2276 disp->visual = FB_VISUAL_PSEUDOCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2277 v.red.offset = v.green.offset = v.blue.offset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2278 v.red.length = v.green.length = v.blue.length = 8;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2279 v.transp.offset = v.transp.length = 0;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2280 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2281 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2282
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2283 #ifdef FBCON_HAS_CFB16
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2284 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2285 nom = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2286 den = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2287 disp->line_length = v.xres_virtual * 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2288 disp->visual = FB_VISUAL_DIRECTCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2289 v.red.offset = 11;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2290 v.green.offset = 5;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2291 v.blue.offset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2292 v.red.length = 5;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2293 v.green.length = 6;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2294 v.blue.length = 5;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2295 v.transp.offset = v.transp.length = 0;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2296 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2297 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2298
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2299 #ifdef FBCON_HAS_CFB24
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2300 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2301 nom = 4;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2302 den = 1;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2303 disp->line_length = v.xres_virtual * 3;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2304 disp->visual = FB_VISUAL_DIRECTCOLOR;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2305 v.red.offset = 16;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2306 v.green.offset = 8;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2307 v.blue.offset = 0;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2308 v.red.length = v.blue.length = v.green.length = 8;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2309 v.transp.offset = v.transp.length = 0;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2310 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2311 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2312 #ifdef FBCON_HAS_CFB32
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2313 case 32:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2314 nom = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2315 den = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2316 disp->line_length = v.xres_virtual * 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2317 disp->visual = FB_VISUAL_DIRECTCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2318 v.red.offset = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2319 v.green.offset = 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2320 v.blue.offset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2321 v.red.length = v.blue.length = v.green.length = 8;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2322 v.transp.offset = 24;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2323 v.transp.length = 8;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2324 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2325 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2326 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2327 printk ("radeonfb: mode %dx%dx%d rejected, color depth invalid\n",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2328 var->xres, var->yres, var->bits_per_pixel);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2329 return -EINVAL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2330 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2331
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2332 if (radeonfb_do_maximize(rinfo, var, &v, nom, den) < 0)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2333 return -EINVAL;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2334
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2335 if (v.xoffset < 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2336 v.xoffset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2337 if (v.yoffset < 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2338 v.yoffset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2339
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2340 if (v.xoffset > v.xres_virtual - v.xres)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2341 v.xoffset = v.xres_virtual - v.xres - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2342
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2343 if (v.yoffset > v.yres_virtual - v.yres)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2344 v.yoffset = v.yres_virtual - v.yres - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2345
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2346 v.red.msb_right = v.green.msb_right = v.blue.msb_right =
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2347 v.transp.offset = v.transp.length =
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2348 v.transp.msb_right = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2349
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2350 switch (v.activate & FB_ACTIVATE_MASK) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2351 case FB_ACTIVATE_TEST:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2352 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2353 case FB_ACTIVATE_NXTOPEN:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2354 case FB_ACTIVATE_NOW:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2355 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2356 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2357 return -EINVAL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2358 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2359
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2360 memcpy (&disp->var, &v, sizeof (v));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2361
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2362 if (chgvar) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2363 radeon_set_dispsw(rinfo, disp);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2364
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2365 if (noaccel)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2366 disp->scrollmode = SCROLL_YREDRAW;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2367 else
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2368 disp->scrollmode = 0;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2369
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2370 if (info && info->changevar)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2371 info->changevar(con);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2372 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2373
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2374 err = radeon_load_video_mode (rinfo, &v);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2375 if(err) return err;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2376 do_install_cmap(con, info);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2377
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2378 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2379 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2380
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2381
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2382
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2383 static int radeonfb_get_cmap (struct fb_cmap *cmap, int kspc, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2384 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2385 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2386 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2387 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2388
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2389 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2390
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2391 if (con == rinfo->currcon) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2392 int rc = fb_get_cmap (cmap, kspc, radeon_getcolreg, info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2393 return rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2394 } else if (disp->cmap.len)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2395 fb_copy_cmap (&disp->cmap, cmap, kspc ? 0 : 2);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2396 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2397 fb_copy_cmap (fb_default_cmap (radeon_get_cmap_len (&disp->var)),
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2398 cmap, kspc ? 0 : 2);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2399
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2400 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2401 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2402
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2403
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2404
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2405 static int radeonfb_set_cmap (struct fb_cmap *cmap, int kspc, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2406 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2407 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2408 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2409 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2410 unsigned int cmap_len;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2411
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2412 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2413
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2414 cmap_len = radeon_get_cmap_len (&disp->var);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2415 if (disp->cmap.len != cmap_len) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2416 int err = fb_alloc_cmap (&disp->cmap, cmap_len, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2417 if (err)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2418 return err;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2419 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2420
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2421 if (con == rinfo->currcon) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2422 int rc = fb_set_cmap (cmap, kspc, radeon_setcolreg, info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2423 return rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2424 } else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2425 fb_copy_cmap (cmap, &disp->cmap, kspc ? 0 : 1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2426
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2427 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2428 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2429
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2430
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2431
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2432 static int radeonfb_pan_display (struct fb_var_screeninfo *var, int con,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2433 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2434 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2435 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2436 u32 offset, xoffset, yoffset;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2437
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2438 xoffset = (var->xoffset + 7) & ~7;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2439 yoffset = var->yoffset;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2440
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2441 if ((xoffset + var->xres > var->xres_virtual) || (yoffset+var->yres >
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2442 var->yres_virtual))
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2443 return -EINVAL;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2444
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2445 offset = ((yoffset * var->xres + xoffset) * var->bits_per_pixel) >> 6;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2446
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2447 OUTREG(CRTC_OFFSET, offset);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2448
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2449 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2450 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2451
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2452
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2453 static void do_install_cmap(int con, struct fb_info *info)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2454 {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2455 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2456
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2457 if (con != rinfo->currcon)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2458 return;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2459
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2460 if (fb_display[con].cmap.len)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2461 fb_set_cmap(&fb_display[con].cmap, 1, radeon_setcolreg, info);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2462 else {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2463 int size = fb_display[con].var.bits_per_pixel == 8 ? 256 : 32;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2464 fb_set_cmap(fb_default_cmap(size), 1, radeon_setcolreg, info);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2465 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2466 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2467
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2468
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2469 static int radeonfb_do_maximize(struct radeonfb_info *rinfo,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2470 struct fb_var_screeninfo *var,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2471 struct fb_var_screeninfo *v,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2472 int nom, int den)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2473 {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2474 static struct {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2475 int xres, yres;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2476 } modes[] = {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2477 {1600, 1280},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2478 {1280, 1024},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2479 {1024, 768},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2480 {800, 600},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2481 {640, 480},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2482 {-1, -1}
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2483 };
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2484 int i;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2485
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2486 /* use highest possible virtual resolution */
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2487 if (v->xres_virtual == -1 && v->yres_virtual == -1) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2488 printk("radeonfb: using max availabe virtual resolution\n");
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2489 for (i=0; modes[i].xres != -1; i++) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2490 if (modes[i].xres * nom / den * modes[i].yres <
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2491 rinfo->video_ram / 2)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2492 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2493 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2494 if (modes[i].xres == -1) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2495 printk("radeonfb: could not find virtual resolution that fits into video memory!\n");
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2496 return -EINVAL;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2497 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2498 v->xres_virtual = modes[i].xres;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2499 v->yres_virtual = modes[i].yres;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2500
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2501 printk("radeonfb: virtual resolution set to max of %dx%d\n",
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2502 v->xres_virtual, v->yres_virtual);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2503 } else if (v->xres_virtual == -1) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2504 v->xres_virtual = (rinfo->video_ram * den /
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2505 (nom * v->yres_virtual * 2)) & ~15;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2506 } else if (v->yres_virtual == -1) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2507 v->xres_virtual = (v->xres_virtual + 15) & ~15;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2508 v->yres_virtual = rinfo->video_ram * den /
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2509 (nom * v->xres_virtual *2);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2510 } else {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2511 if (v->xres_virtual * nom / den * v->yres_virtual >
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2512 rinfo->video_ram) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2513 return -EINVAL;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2514 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2515 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2516
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2517 if (v->xres_virtual * nom / den >= 8192) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2518 v->xres_virtual = 8192 * den / nom - 16;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2519 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2520
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2521 if (v->xres_virtual < v->xres)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2522 return -EINVAL;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2523
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2524 if (v->yres_virtual < v->yres)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2525 return -EINVAL;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2526
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2527 return 0;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2528 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2529
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2530
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2531 static int radeonfb_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2532 unsigned long arg, int con, struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2533 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2534 return -EINVAL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2535 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2536
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2537
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2538
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2539 static int radeonfb_switch (int con, struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2540 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2541 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2542 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2543 struct fb_cmap *cmap;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2544 int switchcon = 0;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2545
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2546 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2547
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2548 if (rinfo->currcon >= 0) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2549 cmap = &(rinfo->currcon_display->cmap);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2550 if (cmap->len)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2551 fb_get_cmap (cmap, 1, radeon_getcolreg, info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2552 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2553
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2554 if ((disp->var.xres != rinfo->xres) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2555 (disp->var.yres != rinfo->yres) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2556 (disp->var.pixclock != rinfo->pixclock) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2557 (disp->var.bits_per_pixel != rinfo->depth))
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2558 switchcon = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2559
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2560 if (switchcon) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2561 rinfo->currcon = con;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2562 rinfo->currcon_display = disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2563 disp->var.activate = FB_ACTIVATE_NOW;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2564
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2565 radeonfb_set_var (&disp->var, con, info);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2566 radeon_set_dispsw (rinfo, disp);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2567 do_install_cmap(con, info);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2568 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2569 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2570 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2571
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2572
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2573
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2574 static int radeonfb_updatevar (int con, struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2575 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2576 int rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2577
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2578 rc = (con < 0) ? -EINVAL : radeonfb_pan_display (&fb_display[con].var,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2579 con, info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2580
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2581 return rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2582 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2583
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2584 static void radeonfb_blank (int blank, struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2585 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2586 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2587 u32 val = INREG(CRTC_EXT_CNTL);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2588
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2589 /* reset it */
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2590 val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS |
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2591 CRTC_VSYNC_DIS);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2592
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2593 switch (blank) {
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2594 case VESA_NO_BLANKING:
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2595 if(DUAL_MONITOR(rinfo)) {
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2596 OUTREGP(CRTC2_GEN_CNTL,
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2597 0,
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2598 ~(CRTC2_DISP_DIS |
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2599 CRTC2_VSYNC_DIS |
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2600 CRTC2_HSYNC_DIS));
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2601 }
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2602 switch(PRIMARY_MONITOR(rinfo)) {
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2603 case MT_LCD:
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2604 OUTREGP(LVDS_GEN_CNTL, 0,
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2605 ~LVDS_DISPLAY_DIS);
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2606 case MT_CRT:
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2607 case MT_DFP:
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2608 OUTREGP(CRTC_EXT_CNTL,
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2609 CRTC_CRT_ON,
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2610 ~(CRTC_DISPLAY_DIS |
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2611 CRTC_VSYNC_DIS |
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2612 CRTC_HSYNC_DIS));
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2613 break;
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2614 case MT_NONE:
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2615 default:
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2616 break;
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2617
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2618 }
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2619 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2620 case VESA_VSYNC_SUSPEND:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2621 val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2622 break;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2623 case VESA_HSYNC_SUSPEND:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2624 val |= (CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2625 break;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2626 case VESA_POWERDOWN:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2627 val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS |
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2628 CRTC_HSYNC_DIS);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2629 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2630 }
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2631 if(blank != VESA_NO_BLANKING) OUTREG(CRTC_EXT_CNTL, val);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2632 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2633
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2634
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2635
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2636 static int radeon_get_cmap_len (const struct fb_var_screeninfo *var)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2637 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2638 int rc = 16; /* reasonable default */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2639
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2640 switch (var->bits_per_pixel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2641 case 8:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2642 rc = 256;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2643 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2644 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2645 rc = 64;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2646 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2647 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2648 rc = 32;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2649 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2650 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2651
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2652 return rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2653 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2654
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2655
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2656
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2657 static int radeon_getcolreg (unsigned regno, unsigned *red, unsigned *green,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2658 unsigned *blue, unsigned *transp,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2659 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2660 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2661 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2662
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2663 if (regno > 255)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2664 return 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2665
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2666 *red = (rinfo->palette[regno].red<<8) | rinfo->palette[regno].red;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2667 *green = (rinfo->palette[regno].green<<8) | rinfo->palette[regno].green;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2668 *blue = (rinfo->palette[regno].blue<<8) | rinfo->palette[regno].blue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2669 *transp = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2670
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2671 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2672 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2673
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2674
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2675
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2676 static int radeon_setcolreg (unsigned regno, unsigned red, unsigned green,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2677 unsigned blue, unsigned transp, struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2678 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2679 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2680 u32 pindex;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2681
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2682 if (regno > 255)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2683 return 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2684
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2685 red >>= 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2686 green >>= 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2687 blue >>= 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2688 rinfo->palette[regno].red = red;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2689 rinfo->palette[regno].green = green;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2690 rinfo->palette[regno].blue = blue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2691
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2692 /* init gamma for hicolor */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2693 if ((rinfo->depth > 8) && (regno == 0)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2694 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2695
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2696 for (i=0; i<255; i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2697 OUTREG(PALETTE_INDEX, i);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2698 OUTREG(PALETTE_DATA, (i << 16) | (i << 8) | i);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2699 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2700 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2701
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2702 /* default */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2703 pindex = regno;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2704
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2705 /* XXX actually bpp, fixme */
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2706 if (rinfo->depth == 16)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2707 pindex = regno * 8;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2708
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2709 if (rinfo->depth == 16) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2710 OUTREG(PALETTE_INDEX, pindex/2);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2711 OUTREG(PALETTE_DATA, (rinfo->palette[regno/2].red << 16) |
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2712 (green << 8) | (rinfo->palette[regno/2].blue));
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2713 green = rinfo->palette[regno/2].green;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2714 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2715
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2716 if ((rinfo->depth == 8) || (regno < 32)) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2717 OUTREG(PALETTE_INDEX, pindex);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2718 OUTREG(PALETTE_DATA, (red << 16) | (green << 8) | blue);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2719 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2720
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2721 #if defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2722 if (regno < 32) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2723 switch (rinfo->depth) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2724 #ifdef FBCON_HAS_CFB16
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2725 case 16:
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2726 rinfo->con_cmap.cfb16[regno] = (regno << 11) | (regno << 5) |
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2727 regno;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2728 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2729 #endif
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2730 #ifdef FBCON_HAS_CFB24
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2731 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2732 rinfo->con_cmap.cfb24[regno] = (regno << 16) | (regno << 8) | regno;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2733 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2734 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2735 #ifdef FBCON_HAS_CFB32
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2736 case 32: {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2737 u32 i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2738
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2739 i = (regno << 8) | regno;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2740 rinfo->con_cmap.cfb32[regno] = (i << 16) | i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2741 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2742 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2743 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2744 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2745 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2746 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2747 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2748 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2749
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2750 static void radeon_save_common_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2751 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2752 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2753 RTRACE("radeonfb: radeon_save_common_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2754 save->ovr_clr = INREG(OVR_CLR);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2755 save->ovr_wid_left_right= INREG(OVR_WID_LEFT_RIGHT);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2756 save->ovr_wid_top_bottom= INREG(OVR_WID_TOP_BOTTOM);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2757 save->ov0_scale_cntl = INREG(OV0_SCALE_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2758 save->mpp_tb_config = INREG(MPP_TB_CONFIG);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2759 save->mpp_gp_config = INREG(MPP_GP_CONFIG);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2760 save->subpic_cntl = INREG(SUBPIC_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2761 save->i2c_cntl_1 = INREG(I2C_CNTL_1);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2762 save->gen_int_cntl = INREG(GEN_INT_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2763 save->cap0_trig_cntl = INREG(CAP0_TRIG_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2764 save->cap1_trig_cntl = INREG(CAP1_TRIG_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2765 save->bus_cntl = INREG(BUS_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2766 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2767
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2768 static void radeon_save_crtc_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2769 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2770 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2771 RTRACE("radeonfb: radeon_save_crtc_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2772 save->crtc_gen_cntl = INREG(CRTC_GEN_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2773 save->crtc_ext_cntl = INREG(CRTC_EXT_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2774 save->dac_cntl = INREG(DAC_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2775 save->crtc_h_total_disp = INREG(CRTC_H_TOTAL_DISP);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2776 save->crtc_h_sync_strt_wid = INREG(CRTC_H_SYNC_STRT_WID);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2777 save->crtc_v_total_disp = INREG(CRTC_V_TOTAL_DISP);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2778 save->crtc_v_sync_strt_wid = INREG(CRTC_V_SYNC_STRT_WID);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2779 save->crtc_offset = INREG(CRTC_OFFSET);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2780 save->crtc_offset_cntl = INREG(CRTC_OFFSET_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2781 save->crtc_pitch = INREG(CRTC_PITCH);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2782 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2783
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2784 static void radeon_save_crtc2_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2785 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2786 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2787 RTRACE("radeonfb: radeon_save_crtc2_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2788 save->dac2_cntl = INREG(DAC_CNTL2);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2789 save->disp_output_cntl = INREG(DISP_OUTPUT_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2790
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2791 save->crtc2_gen_cntl = INREG(CRTC2_GEN_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2792 save->crtc2_h_total_disp = INREG(CRTC2_H_TOTAL_DISP);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2793 save->crtc2_h_sync_strt_wid = INREG(CRTC2_H_SYNC_STRT_WID);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2794 save->crtc2_v_total_disp = INREG(CRTC2_V_TOTAL_DISP);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2795 save->crtc2_v_sync_strt_wid = INREG(CRTC2_V_SYNC_STRT_WID);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2796 save->crtc2_offset = INREG(CRTC2_OFFSET);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2797 save->crtc2_offset_cntl = INREG(CRTC2_OFFSET_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2798 save->crtc2_pitch = INREG(CRTC2_PITCH);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2799 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2800
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2801 static void radeon_save_fp_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2802 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2803 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2804 RTRACE("radeonfb: radeon_save_fp_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2805 save->fp_crtc_h_total_disp = INREG(FP_CRTC_H_TOTAL_DISP);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2806 save->fp_crtc_v_total_disp = INREG(FP_CRTC_V_TOTAL_DISP);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2807 save->fp_gen_cntl = INREG(FP_GEN_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2808 save->fp_h_sync_strt_wid = INREG(FP_H_SYNC_STRT_WID);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2809 save->fp_horz_stretch = INREG(FP_HORZ_STRETCH);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2810 save->fp_v_sync_strt_wid = INREG(FP_V_SYNC_STRT_WID);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2811 save->fp_vert_stretch = INREG(FP_VERT_STRETCH);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2812 save->lvds_gen_cntl = INREG(LVDS_GEN_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2813 save->lvds_pll_cntl = INREG(LVDS_PLL_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2814 save->tmds_crc = INREG(TMDS_CRC);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2815 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2816
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2817 static void radeon_save_pll_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2818 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2819 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2820 RTRACE("radeonfb: radeon_save_pll_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2821 save->ppll_ref_div = INPLL(PPLL_REF_DIV);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2822 save->ppll_div_3 = INPLL(PPLL_DIV_3);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2823 save->htotal_cntl = INPLL(HTOTAL_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2824 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2825
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2826 static void radeon_save_pll2_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2827 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2828 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2829 RTRACE("radeonfb: radeon_save_pll2_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2830 save->p2pll_ref_div = INPLL(P2PLL_REF_DIV);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2831 save->p2pll_div_0 = INPLL(P2PLL_DIV_0);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2832 save->htotal_cntl2 = INPLL(HTOTAL2_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2833 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2834
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2835 static void radeon_save_dda_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2836 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2837 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2838 RTRACE("radeonfb: radeon_save_dda_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2839 save->dda_config = INREG(DDA_CONFIG);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2840 save->dda_on_off = INREG(DDA_ON_OFF);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2841 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2842
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2843 static void radeon_write_common_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2844 struct radeon_regs *restore)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2845 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2846 RTRACE("radeonfb: radeon_write_common_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2847 OUTREG(OVR_CLR, restore->ovr_clr);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2848 OUTREG(OVR_WID_LEFT_RIGHT, restore->ovr_wid_left_right);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2849 OUTREG(OVR_WID_TOP_BOTTOM, restore->ovr_wid_top_bottom);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2850 OUTREG(OV0_SCALE_CNTL, restore->ov0_scale_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2851 OUTREG(MPP_TB_CONFIG, restore->mpp_tb_config );
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2852 OUTREG(MPP_GP_CONFIG, restore->mpp_gp_config );
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2853 OUTREG(SUBPIC_CNTL, restore->subpic_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2854 OUTREG(I2C_CNTL_1, restore->i2c_cntl_1);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2855 OUTREG(GEN_INT_CNTL, restore->gen_int_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2856 OUTREG(CAP0_TRIG_CNTL, restore->cap0_trig_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2857 OUTREG(CAP1_TRIG_CNTL, restore->cap1_trig_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2858 OUTREG(BUS_CNTL, restore->bus_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2859 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2860
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2861 static void radeon_write_crtc_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2862 struct radeon_regs *restore)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2863 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2864 RTRACE("radeonfb: radeon_write_crtc_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2865 OUTREG(CRTC_GEN_CNTL, restore->crtc_gen_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2866
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2867 OUTREGP(CRTC_EXT_CNTL, restore->crtc_ext_cntl,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2868 CRTC_VSYNC_DIS |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2869 CRTC_HSYNC_DIS |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2870 CRTC_DISPLAY_DIS);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2871
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2872 OUTREGP(DAC_CNTL, restore->dac_cntl,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2873 DAC_RANGE_CNTL |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2874 DAC_BLANKING);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2875
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2876 OUTREG(CRTC_H_TOTAL_DISP, restore->crtc_h_total_disp);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2877 OUTREG(CRTC_H_SYNC_STRT_WID, restore->crtc_h_sync_strt_wid);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2878 OUTREG(CRTC_V_TOTAL_DISP, restore->crtc_v_total_disp);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2879 OUTREG(CRTC_V_SYNC_STRT_WID, restore->crtc_v_sync_strt_wid);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2880 OUTREG(CRTC_OFFSET, restore->crtc_offset);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2881 OUTREG(CRTC_OFFSET_CNTL, restore->crtc_offset_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2882 OUTREG(CRTC_PITCH, restore->crtc_pitch);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2883 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2884
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2885 static void radeon_write_crtc2_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2886 struct radeon_regs *restore)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2887 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2888 RTRACE("radeonfb: radeon_write_crtc2_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2889 /* OUTREG(CRTC2_GEN_CNTL, restore->crtc2_gen_cntl);*/
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2890 OUTREGP(CRTC2_GEN_CNTL, restore->crtc2_gen_cntl,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2891 CRTC2_VSYNC_DIS |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2892 CRTC2_HSYNC_DIS |
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2893 CRTC2_DISP_DIS);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2894
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2895 OUTREG(DAC_CNTL2, restore->dac2_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2896 OUTREG(DISP_OUTPUT_CNTL, restore->disp_output_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2897
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2898 OUTREG(CRTC2_H_TOTAL_DISP, restore->crtc2_h_total_disp);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2899 OUTREG(CRTC2_H_SYNC_STRT_WID, restore->crtc2_h_sync_strt_wid);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2900 OUTREG(CRTC2_V_TOTAL_DISP, restore->crtc2_v_total_disp);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2901 OUTREG(CRTC2_V_SYNC_STRT_WID, restore->crtc2_v_sync_strt_wid);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2902 OUTREG(CRTC2_OFFSET, restore->crtc2_offset);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2903 OUTREG(CRTC2_OFFSET_CNTL, restore->crtc2_offset_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2904 OUTREG(CRTC2_PITCH, restore->crtc2_pitch);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2905 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2906
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2907 static void radeon_write_fp_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2908 struct radeon_regs *restore)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2909 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2910 int prim_mon;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2911 u32 tmp;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2912 RTRACE("radeonfb: radeon_write_fp_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2913 OUTREG(FP_CRTC_H_TOTAL_DISP, restore->fp_crtc_h_total_disp);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2914 OUTREG(FP_CRTC_V_TOTAL_DISP, restore->fp_crtc_v_total_disp);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2915 OUTREG(FP_H_SYNC_STRT_WID, restore->fp_h_sync_strt_wid);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2916 OUTREG(FP_V_SYNC_STRT_WID, restore->fp_v_sync_strt_wid);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2917 OUTREG(TMDS_CRC, restore->tmds_crc);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2918 OUTREG(FP_HORZ_STRETCH, restore->fp_horz_stretch);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2919 OUTREG(FP_VERT_STRETCH, restore->fp_vert_stretch);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2920 OUTREG(FP_GEN_CNTL, restore->fp_gen_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2921 prim_mon = PRIMARY_MONITOR(rinfo);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2922 if(prim_mon == MT_LCD) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2923 tmp = INREG(LVDS_GEN_CNTL);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2924 if((tmp & (LVDS_ON | LVDS_BLON)) ==
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2925 (restore->lvds_gen_cntl & (LVDS_ON | LVDS_BLON))) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2926 OUTREG(LVDS_GEN_CNTL, restore->lvds_gen_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2927 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2928 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2929 else {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2930 if (restore->lvds_gen_cntl & (LVDS_ON | LVDS_BLON)) {
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2931 udelay(rinfo->PanelPwrDly * 1000);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2932 OUTREG(LVDS_GEN_CNTL, restore->lvds_gen_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2933 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2934 else {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2935 OUTREG(LVDS_GEN_CNTL,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2936 restore->lvds_gen_cntl | LVDS_BLON);
2142
8939341c5187 Some fixes
nick
parents: 2136
diff changeset
2937 udelay(rinfo->PanelPwrDly * 1000);
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2938 OUTREG(LVDS_GEN_CNTL, restore->lvds_gen_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2939 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2940 }
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2941 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2942
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2943 static void radeon_write_pll_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2944 struct radeon_regs *restore)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2945 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2946 RTRACE("radeonfb: radeon_write_pll_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2947 OUTPLLP(0x08, 0x00, ~(0x03));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2948 while ( (INREG(CLOCK_CNTL_INDEX) & PLL_DIV_SEL) != PLL_DIV_SEL) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2949 OUTREGP(CLOCK_CNTL_INDEX, PLL_DIV_SEL, 0xffff);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2950 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2951 OUTPLLP(PPLL_CNTL, PPLL_RESET, 0xffff);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2952 while ( (INPLL(PPLL_REF_DIV) & PPLL_REF_DIV_MASK) !=
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2953 (restore->ppll_ref_div & PPLL_REF_DIV_MASK)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2954 OUTPLLP(PPLL_REF_DIV,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2955 restore->ppll_ref_div, ~PPLL_REF_DIV_MASK);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2956 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2957 while ( (INPLL(PPLL_DIV_3) & PPLL_FB3_DIV_MASK) !=
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2958 (restore->ppll_div_3 & PPLL_FB3_DIV_MASK)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2959 OUTPLLP(PPLL_DIV_3,restore->ppll_div_3, ~PPLL_FB3_DIV_MASK);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2960 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2961 while ( (INPLL(PPLL_DIV_3) & PPLL_POST3_DIV_MASK) !=
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2962 (restore->ppll_div_3 & PPLL_POST3_DIV_MASK)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2963 OUTPLLP(PPLL_DIV_3,restore->ppll_div_3, ~PPLL_POST3_DIV_MASK);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2964 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2965 OUTPLL(HTOTAL_CNTL, restore->htotal_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2966 OUTPLLP(PPLL_CNTL, 0, ~PPLL_RESET);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2967 OUTPLLP(0x08, 0x03, ~(0x03));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2968 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2969
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2970
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2971 static void radeon_write_pll2_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2972 struct radeon_regs *restore)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2973 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2974 RTRACE("radeonfb: radeon_write_pll2_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2975 OUTPLLP(0x2d, 0x00, ~(0x03));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2976 while (INREG(CLOCK_CNTL_INDEX) & ~(PLL2_DIV_SEL_MASK)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2977 OUTREGP(CLOCK_CNTL_INDEX, 0, PLL2_DIV_SEL_MASK);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2978 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2979 OUTPLLP(P2PLL_CNTL,P2PLL_RESET,0xffff);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2980 while ( (INPLL(P2PLL_REF_DIV) & P2PLL_REF_DIV_MASK) !=
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2981 (restore->p2pll_ref_div & P2PLL_REF_DIV_MASK)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2982 OUTPLLP(P2PLL_REF_DIV, restore->p2pll_ref_div, ~P2PLL_REF_DIV_MASK);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2983 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2984 while ( (INPLL(P2PLL_DIV_0) & P2PLL_FB0_DIV_MASK) !=
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2985 (restore->p2pll_div_0 & P2PLL_FB0_DIV_MASK)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2986 OUTPLLP(P2PLL_DIV_0, restore->p2pll_div_0, ~P2PLL_FB0_DIV_MASK);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2987 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2988 while ( (INPLL(P2PLL_DIV_0) & P2PLL_POST0_DIV_MASK) !=
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2989 (restore->p2pll_div_0 & P2PLL_POST0_DIV_MASK)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2990 OUTPLLP(P2PLL_DIV_0,restore->p2pll_div_0, ~P2PLL_POST0_DIV_MASK);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2991 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2992 OUTPLL(HTOTAL2_CNTL, restore->htotal_cntl2);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2993 OUTPLLP(P2PLL_CNTL, 0, ~(P2PLL_RESET | P2PLL_SLEEP));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2994 OUTPLLP(0x2d, 0x03, ~(0x03));
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2995 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2996
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2997 static void radeon_write_dda_regs(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2998 struct radeon_regs *restore)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
2999 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3000 RTRACE("radeonfb: radeon_write_dda_regs is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3001 OUTREG(DDA_CONFIG, restore->dda_config);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3002 OUTREG(DDA_ON_OFF, restore->dda_on_off);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3003 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3004
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3005 static void radeon_save_mode (struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3006 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3007 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3008 int prim_mon;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3009 RTRACE("radeonfb: radeon_save_mode is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3010 if(DUAL_MONITOR(rinfo)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3011 radeon_save_crtc2_regs(rinfo,save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3012 radeon_save_pll2_regs(rinfo,save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3013 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3014 radeon_save_common_regs(rinfo,save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3015 radeon_save_crtc_regs(rinfo,save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3016 prim_mon = PRIMARY_MONITOR(rinfo);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3017 if(prim_mon == MT_LCD || prim_mon == MT_DFP) radeon_save_fp_regs(rinfo,save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3018 radeon_save_pll_regs(rinfo,save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3019 radeon_save_dda_regs(rinfo,save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3020 /*radeon_save_palette(rinfo,save);*/
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3021 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3022
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3023 static void radeon_save_state(struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3024 struct radeon_regs *save)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3025 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3026 RTRACE("radeonfb: radeon_save_state is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3027 save->dp_datatype = INREG(DP_DATATYPE);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3028 save->rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3029 save->clock_cntl_index = INREG(CLOCK_CNTL_INDEX);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3030 save->amcgpio_en_reg = INREG(AMCGPIO_EN_REG);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3031 save->amcgpio_mask = INREG(AMCGPIO_MASK);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3032 radeon_save_mode(rinfo,save);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3033 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3034
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
3035 static int radeon_load_video_mode (struct radeonfb_info *rinfo,
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3036 struct fb_var_screeninfo *mode)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3037 {
2134
27bfb445ca85 Fully enabled new logic
nick
parents: 2133
diff changeset
3038
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3039 struct radeon_regs newmode;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3040
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3041 RTRACE("radeonfb: radeon_load_video_mode is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3042 if(!radeon_init_mode(rinfo, &newmode, mode)) return -1;
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3043
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3044 radeonfb_blank(VESA_POWERDOWN,&rinfo->info);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3045 radeon_write_mode(rinfo, &newmode);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3046 radeonfb_blank(VESA_NO_BLANKING,&rinfo->info);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3047 return 0;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3048 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3049
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3050 static void radeon_write_mode (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3051 struct radeon_regs *mode)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3052 {
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3053 /*****
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3054 When changing mode with Dual-head card (VE/M6), care must
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3055 be taken for the special order in setting registers. CRTC2 has
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3056 to be set before changing CRTC_EXT register.
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3057 Otherwise we may get a blank screen.
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3058 *****/
2136
f13d61fde30d Fixed bug of FP register writing
nick
parents: 2135
diff changeset
3059 int prim_mon;
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3060 RTRACE("radeonfb: radeon_write_mode is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3061 if(DUAL_MONITOR(rinfo)) {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3062 radeon_write_crtc2_regs(rinfo,mode);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3063 radeon_write_pll2_regs(rinfo,mode);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3064 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3065 radeon_write_common_regs(rinfo,mode);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3066 radeon_write_dda_regs(rinfo,mode);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3067 radeon_write_crtc_regs(rinfo,mode);
2136
f13d61fde30d Fixed bug of FP register writing
nick
parents: 2135
diff changeset
3068 prim_mon = PRIMARY_MONITOR(rinfo);
f13d61fde30d Fixed bug of FP register writing
nick
parents: 2135
diff changeset
3069 if(prim_mon == MT_DFP || prim_mon == MT_LCD) {
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3070 radeon_write_fp_regs(rinfo,mode);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3071 }
2132
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3072 radeon_write_pll_regs(rinfo,mode);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3073 }
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3074
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3075 static void radeon_write_state (struct radeonfb_info *rinfo,
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3076 struct radeon_regs *restore)
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3077 {
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3078 RTRACE("radeonfb: radeon_write_state is called\n");
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3079 radeonfb_blank(VESA_POWERDOWN,&rinfo->info);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3080 OUTREG(AMCGPIO_MASK, restore->amcgpio_mask);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3081 OUTREG(AMCGPIO_EN_REG, restore->amcgpio_en_reg);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3082 OUTREG(CLOCK_CNTL_INDEX,restore->clock_cntl_index);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3083 OUTREG(RBBM_SOFT_RESET, restore->rbbm_soft_reset);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3084 OUTREG(DP_DATATYPE, restore->dp_datatype);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3085 /* M6 card has trouble restoring text mode for its CRT.
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3086 Needs this workaround.*/
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3087 if(rinfo->isM6) OUTREG(DAC_CNTL2, restore->dac2_cntl);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3088 radeon_write_mode(rinfo,restore);
94617874ed1c Imported some XFree86-CVS stuff
nick
parents: 2046
diff changeset
3089 radeonfb_blank(VESA_NO_BLANKING,&rinfo->info);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3090 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3091
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
3092 #if 0
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3093 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3094 * text console acceleration
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3095 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3096
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3097
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3098 static void fbcon_radeon_bmove(struct display *p, int srcy, int srcx,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3099 int dsty, int dstx, int height, int width)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3100 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3101 struct radeonfb_info *rinfo = (struct radeonfb_info *)(p->fb_info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3102 u32 dp_cntl = DST_LAST_PEL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3103
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3104 srcx *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3105 srcy *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3106 dstx *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3107 dsty *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3108 width *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3109 height *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3110
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3111 if (srcy < dsty) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3112 srcy += height - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3113 dsty += height - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3114 } else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3115 dp_cntl |= DST_Y_TOP_TO_BOTTOM;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3116
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3117 if (srcx < dstx) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3118 srcx += width - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3119 dstx += width - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3120 } else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3121 dp_cntl |= DST_X_LEFT_TO_RIGHT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3122
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3123 radeon_fifo_wait(6);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3124 OUTREG(DP_GUI_MASTER_CNTL, (rinfo->dp_gui_master_cntl |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3125 GMC_BRUSH_NONE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3126 GMC_SRC_DATATYPE_COLOR |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3127 ROP3_S |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3128 DP_SRC_SOURCE_MEMORY));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3129 OUTREG(DP_WRITE_MSK, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3130 OUTREG(DP_CNTL, dp_cntl);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3131 OUTREG(SRC_Y_X, (srcy << 16) | srcx);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3132 OUTREG(DST_Y_X, (dsty << 16) | dstx);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3133 OUTREG(DST_HEIGHT_WIDTH, (height << 16) | width);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3134 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3135
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3136 static void fbcon_radeon_clear(struct vc_data *conp, struct display *p,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3137 int srcy, int srcx, int height, int width)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3138 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3139 struct radeonfb_info *rinfo = (struct radeonfb_info *)(p->fb_info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3140 u32 clr;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3141
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3142 clr = attr_bgcol_ec(p, conp);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3143 clr |= (clr << 8);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3144 clr |= (clr << 16);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3145
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3146 srcx *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3147 srcy *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3148 width *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3149 height *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3150
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3151 radeon_fifo_wait(6);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3152 OUTREG(DP_GUI_MASTER_CNTL, (rinfo->dp_gui_master_cntl |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3153 GMC_BRUSH_SOLID_COLOR |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3154 GMC_SRC_DATATYPE_COLOR |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3155 ROP3_P));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3156 OUTREG(DP_BRUSH_FRGD_CLR, clr);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3157 OUTREG(DP_WRITE_MSK, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3158 OUTREG(DP_CNTL, (DST_X_LEFT_TO_RIGHT | DST_Y_TOP_TO_BOTTOM));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3159 OUTREG(DST_Y_X, (srcy << 16) | srcx);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3160 OUTREG(DST_WIDTH_HEIGHT, (width << 16) | height);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3161 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3162
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3163 #ifdef FBCON_HAS_CFB8
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3164 static struct display_switch fbcon_radeon8 = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3165 setup: fbcon_cfb8_setup,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3166 bmove: fbcon_radeon_bmove,
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
3167 clear: fbcon_radeon_clear,
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3168 putc: fbcon_cfb8_putc,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3169 putcs: fbcon_cfb8_putcs,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3170 revc: fbcon_cfb8_revc,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3171 clear_margins: fbcon_cfb8_clear_margins,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3172 fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3173 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
3174 #endif
3555
33bbfea73af3 Partial sync with linux stuff (Linux driver is still buggy for me)
nick
parents: 2160
diff changeset
3175 #endif