annotate drivers/radeon/radeonfb.c @ 4833:395844d9d5d6

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