annotate drivers/radeon/radeonfb.c @ 1914:838bfa146fa3

Merge with Ani Joshi's radeonfb-0.1.0
author nick
date Tue, 18 Sep 2001 16:26:11 +0000
parents 717f46012fce
children 31fdf7bb1a8e
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
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
14 * 2001-09-06 console switching fixes, blanking fixes,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
15 * 0.1.0
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
16 *
1912
33afcb62fc64 Radeon VE support
nick
parents: 1911
diff changeset
17 * 2001-09-07 Radeon VE support
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
18 * 2001-09-10 Radeon VE QZ support by Nick Kurshev <nickols_k@mail.ru>
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
19 * (limitations: on dualhead Radeons (VE, M6, M7)
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
20 * driver works only on second head (DVI port).
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
21 * TVout is not supported too. M6 & M7 chips
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
22 * currently are not supported. Driver has a lot
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
23 * of other bugs. Probably they can be solved by
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
24 * importing XFree86 code, which has ATI's support).,
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
25 * 0.0.11
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
26 * 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
27 * console switching fixes, blanking fixes,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
28 * 0.1.0-ve.0
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
29 *
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
30 * 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
31 *
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
32 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
33
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
34
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
35 #define RADEON_VERSION "0.1.0-ve.0"
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
36
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
37
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
38 #include <linux/config.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
39 #include <linux/module.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
40 #include <linux/kernel.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
41 #include <linux/errno.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
42 #include <linux/string.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
43 #include <linux/mm.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
44 #include <linux/tty.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
45 #include <linux/malloc.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
46 #include <linux/delay.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
47 #include <linux/fb.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
48 #include <linux/console.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
49 #include <linux/selection.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
50 #include <linux/ioport.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
51 #include <linux/init.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
52 #include <linux/pci.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
53
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
54 #include <asm/io.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
55
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
56 #include <video/fbcon.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
57 #include <video/fbcon-cfb8.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
58 #include <video/fbcon-cfb16.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
59 #include <video/fbcon-cfb24.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
60 #include <video/fbcon-cfb32.h>
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
61
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
62 #include "radeon.h"
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
63
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
64
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
65 #define DEBUG 0
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
66
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
67 #if DEBUG
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
68 #define RTRACE printk
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
69 #else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
70 #define RTRACE if(0) printk
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
71 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
72
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
73
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
74
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
75 enum radeon_chips {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
76 RADEON_QD,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
77 RADEON_QE,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
78 RADEON_QF,
1912
33afcb62fc64 Radeon VE support
nick
parents: 1911
diff changeset
79 RADEON_QG,
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
80 RADEON_QY,
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
81 RADEON_QZ
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
82 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
83
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
84
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
85 static struct pci_device_id radeonfb_pci_table[] __devinitdata = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
86 { 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
87 { 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
88 { 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
89 { 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
90 { 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
91 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_RADEON_QZ, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RADEON_QZ},
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
92 { 0, }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
93 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
94 MODULE_DEVICE_TABLE(pci, radeonfb_pci_table);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
95
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 typedef struct {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
98 u16 reg;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
99 u32 val;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
100 } reg_val;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
101
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
102
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
103 /* these common regs are cleared before mode setting so they do not
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
104 * interfere with anything
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
105 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
106 reg_val common_regs[] = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
107 { OVR_CLR, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
108 { OVR_WID_LEFT_RIGHT, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
109 { OVR_WID_TOP_BOTTOM, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
110 { OV0_SCALE_CNTL, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
111 { SUBPIC_CNTL, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
112 { VIPH_CONTROL, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
113 { I2C_CNTL_1, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
114 { GEN_INT_CNTL, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
115 { CAP0_TRIG_CNTL, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
116 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
117
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
118 #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
119
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
120 typedef struct {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
121 u8 clock_chip_type;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
122 u8 struct_size;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
123 u8 accelerator_entry;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
124 u8 VGA_entry;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
125 u16 VGA_table_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
126 u16 POST_table_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
127 u16 XCLK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
128 u16 MCLK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
129 u8 num_PLL_blocks;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
130 u8 size_PLL_blocks;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
131 u16 PCLK_ref_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
132 u16 PCLK_ref_divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
133 u32 PCLK_min_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
134 u32 PCLK_max_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
135 u16 MCLK_ref_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
136 u16 MCLK_ref_divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
137 u32 MCLK_min_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
138 u32 MCLK_max_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
139 u16 XCLK_ref_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
140 u16 XCLK_ref_divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
141 u32 XCLK_min_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
142 u32 XCLK_max_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
143 } __attribute__ ((packed)) PLL_BLOCK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
144
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
145
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
146 struct pll_info {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
147 int ppll_max;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
148 int ppll_min;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
149 int xclk;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
150 int ref_div;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
151 int ref_clk;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
152 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
153
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
154
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
155 struct ram_info {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
156 int ml;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
157 int mb;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
158 int trcd;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
159 int trp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
160 int twr;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
161 int cl;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
162 int tr2w;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
163 int loop_latency;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
164 int rloop;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
165 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
166
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
167
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
168 struct radeon_regs {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
169 u32 crtc_h_total_disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
170 u32 crtc_h_sync_strt_wid;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
171 u32 crtc_v_total_disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
172 u32 crtc_v_sync_strt_wid;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
173 u32 crtc_pitch;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
174 u32 flags;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
175 u32 pix_clock;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
176 int xres, yres;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
177 int bpp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
178 u32 crtc_gen_cntl;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
179 u32 crtc_ext_cntl;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
180 u32 surface_cntl;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
181 u32 dac_cntl;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
182 u32 dda_config;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
183 u32 dda_on_off;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
184 u32 ppll_div_3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
185 u32 ppll_ref_div;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
186 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
187
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
188
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
189 struct radeonfb_info {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
190 struct fb_info info;
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 struct radeon_regs state;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
193 struct radeon_regs init_state;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
194
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
195 char name[14];
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
196 char ram_type[12];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
197
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
198 u32 mmio_base_phys;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
199 u32 fb_base_phys;
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 u32 mmio_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
202 u32 fb_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
203
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
204 struct pci_dev *pdev;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
205
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
206 struct display disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
207 int currcon;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
208 struct display *currcon_display;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
209
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
210 struct { u8 red, green, blue, pad; } palette[256];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
211
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
212 int chipset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
213 int video_ram;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
214 u8 rev;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
215 int pitch, bpp, depth;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
216 int xres, yres, pixclock;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
217
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
218 u32 dp_gui_master_cntl;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
219
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
220 struct pll_info pll;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
221 int pll_output_freq, post_div, fb_div;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
222
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
223 struct ram_info ram;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
224
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
225 u32 hack_crtc_ext_cntl;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
226 u32 hack_crtc_v_sync_strt_wid;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
227
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
228 #if defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
229 union {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
230 #if defined(FBCON_HAS_CFB16)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
231 u_int16_t cfb16[16];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
232 #endif
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
233 #if defined(FBCON_HAS_CFB24)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
234 u_int32_t cfb24[16];
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
235 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
236 #if defined(FBCON_HAS_CFB32)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
237 u_int32_t cfb32[16];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
238 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
239 } con_cmap;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
240 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
241 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
242
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
243
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
244 static struct fb_var_screeninfo radeonfb_default_var = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
245 640, 480, 640, 480, 0, 0, 8, 0,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
246 {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
247 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
248 0, FB_VMODE_NONINTERLACED
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
249 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
250
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
251
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
252 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
253 * IO macros
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
254 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
255
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
256 #define INREG8(addr) readb((rinfo->mmio_base)+addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
257 #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
258 #define INREG(addr) readl((rinfo->mmio_base)+addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
259 #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
260
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
261 #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
262 OUTREG(CLOCK_CNTL_DATA, val)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
263 #define OUTPLLP(addr,val,mask) \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
264 do { \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
265 unsigned int _tmp = INPLL(addr); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
266 _tmp &= (mask); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
267 _tmp |= (val); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
268 OUTPLL(addr, _tmp); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
269 } while (0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
270
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
271 #define OUTREGP(addr,val,mask) \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
272 do { \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
273 unsigned int _tmp = INREG(addr); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
274 _tmp &= (mask); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
275 _tmp |= (val); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
276 OUTREG(addr, _tmp); \
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
277 } while (0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
278
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
279
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
280 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
281 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
282 OUTREG8(CLOCK_CNTL_INDEX, addr & 0x0000001f);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
283 return (INREG(CLOCK_CNTL_DATA));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
284 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
285
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
286 #define INPLL(addr) _INPLL(rinfo, addr)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
287
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
288
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
289 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
290 * 2D engine routines
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
291 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
292
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
293 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
294 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
295 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
296
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
297 /* initiate flush */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
298 OUTREGP(RB2D_DSTCACHE_CTLSTAT, RB2D_DC_FLUSH_ALL,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
299 ~RB2D_DC_FLUSH_ALL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
300
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
301 for (i=0; i < 2000000; i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
302 if (!(INREG(RB2D_DSTCACHE_CTLSTAT) & RB2D_DC_BUSY))
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
303 break;
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
307
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
308 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
309 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
310 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
311
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
312 for (i=0; i<2000000; i++)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
313 if ((INREG(RBBM_STATUS) & 0x7f) >= entries)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
314 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
315 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
316
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
317
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
318 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
319 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
320 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
321
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
322 /* ensure FIFO is empty before waiting for idle */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
323 _radeon_fifo_wait (rinfo, 64);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
324
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
325 for (i=0; i<2000000; i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
326 if (((INREG(RBBM_STATUS) & GUI_ACTIVE)) == 0) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
327 radeon_engine_flush (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
328 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
329 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
330 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
331 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
332
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
333
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
334 #define radeon_engine_idle() _radeon_engine_idle(rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
335 #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
336
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
337
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
338
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
339 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
340 * helper routines
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
341 */
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 static __inline__ u32 radeon_get_dstbpp(u16 depth)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
344 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
345 switch (depth) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
346 case 8:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
347 return DST_8BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
348 case 15:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
349 return DST_15BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
350 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
351 return DST_16BPP;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
352 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
353 return DST_24BPP;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
354 case 32:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
355 return DST_32BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
356 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
357 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
358 }
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
361
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
362 static void _radeon_engine_reset(struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
363 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
364 u32 clock_cntl_index, mclk_cntl, rbbm_soft_reset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
365
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
366 radeon_engine_flush (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
367
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
368 clock_cntl_index = INREG(CLOCK_CNTL_INDEX);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
369 mclk_cntl = INPLL(MCLK_CNTL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
370
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
371 OUTPLL(MCLK_CNTL, (mclk_cntl |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
372 FORCEON_MCLKA |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
373 FORCEON_MCLKB |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
374 FORCEON_YCLKA |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
375 FORCEON_YCLKB |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
376 FORCEON_MC |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
377 FORCEON_AIC));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
378 rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
379
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
380 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
381 SOFT_RESET_CP |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
382 SOFT_RESET_HI |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
383 SOFT_RESET_SE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
384 SOFT_RESET_RE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
385 SOFT_RESET_PP |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
386 SOFT_RESET_E2 |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
387 SOFT_RESET_RB |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
388 SOFT_RESET_HDP);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
389 INREG(RBBM_SOFT_RESET);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
390 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset & (u32)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
391 ~(SOFT_RESET_CP |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
392 SOFT_RESET_HI |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
393 SOFT_RESET_SE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
394 SOFT_RESET_RE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
395 SOFT_RESET_PP |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
396 SOFT_RESET_E2 |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
397 SOFT_RESET_RB |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
398 SOFT_RESET_HDP));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
399 INREG(RBBM_SOFT_RESET);
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 OUTPLL(MCLK_CNTL, mclk_cntl);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
402 OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
403 OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
404
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
405 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
406 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
407
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
408 #define radeon_engine_reset() _radeon_engine_reset(rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
409
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
410
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
411 static __inline__ u8 radeon_get_post_div_bitval(int post_div)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
412 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
413 switch (post_div) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
414 case 1:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
415 return 0x00;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
416 case 2:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
417 return 0x01;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
418 case 3:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
419 return 0x04;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
420 case 4:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
421 return 0x02;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
422 case 6:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
423 return 0x06;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
424 case 8:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
425 return 0x03;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
426 case 12:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
427 return 0x07;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
428 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
429 return 0x02;
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 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
432
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
433
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
434
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
435 static __inline__ int round_div(int num, int den)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
436 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
437 return (num + (den / 2)) / den;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
438 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
439
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
440
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
441
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
442 static __inline__ int min_bits_req(int val)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
443 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
444 int bits_req = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
445
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
446 if (val == 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
447 bits_req = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
448
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
449 while (val) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
450 val >>= 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
451 bits_req++;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
452 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
453
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
454 return (bits_req);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
455 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
456
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
457
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
458 static __inline__ int _max(int val1, int val2)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
459 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
460 if (val1 >= val2)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
461 return val1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
462 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
463 return val2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
464 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
465
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
466
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
467
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
468 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
469 * globals
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
470 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
471
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
472 static char fontname[40] __initdata;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
473 static char *mode_option __initdata;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
474 static char noaccel __initdata = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
475
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
476 #if 0
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
477 #ifdef FBCON_HAS_CFB8
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
478 static struct display_switch fbcon_radeon8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
479 #endif
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
480 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
481
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
482 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
483 * prototypes
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
484 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
485
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
486 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
487 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
488 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
489 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
490 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
491 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
492 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
493 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
494 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
495 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
496 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
497 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
498 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
499 unsigned long arg, int con, struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
500 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
501 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
502 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
503 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
504 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
505 unsigned *blue, unsigned *transp,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
506 struct fb_info *info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
507 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
508 unsigned blue, unsigned transp, struct fb_info *info);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
509 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
510 static void radeon_save_state (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
511 struct radeon_regs *save);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
512 static void radeon_engine_init (struct radeonfb_info *rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
513 static void radeon_load_video_mode (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
514 struct fb_var_screeninfo *mode);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
515 static void radeon_write_mode (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
516 struct radeon_regs *mode);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
517 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
518 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
519 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
520 static int radeonfb_pci_register (struct pci_dev *pdev,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
521 const struct pci_device_id *ent);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
522 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
523 static char *radeon_find_rom(struct radeonfb_info *rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
524 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
525 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
526 static int radeonfb_do_maximize(struct radeonfb_info *rinfo,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
527 struct fb_var_screeninfo *var,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
528 struct fb_var_screeninfo *v,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
529 int nom, int den);
1911
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 static struct fb_ops radeon_fb_ops = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
532 fb_get_fix: radeonfb_get_fix,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
533 fb_get_var: radeonfb_get_var,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
534 fb_set_var: radeonfb_set_var,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
535 fb_get_cmap: radeonfb_get_cmap,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
536 fb_set_cmap: radeonfb_set_cmap,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
537 fb_pan_display: radeonfb_pan_display,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
538 fb_ioctl: radeonfb_ioctl,
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
542 static struct pci_driver radeonfb_driver = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
543 name: "radeonfb",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
544 id_table: radeonfb_pci_table,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
545 probe: radeonfb_pci_register,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
546 remove: radeonfb_pci_unregister,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
547 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
548
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
549
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
550 int __init radeonfb_init (void)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
551 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
552 return pci_module_init (&radeonfb_driver);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
553 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
554
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
555
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
556 void __exit radeonfb_exit (void)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
557 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
558 pci_unregister_driver (&radeonfb_driver);
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 int __init radeonfb_setup (char *options)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
563 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
564 char *this_opt;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
565
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
566 if (!options || !*options)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
567 return 0;
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 for (this_opt = strtok (options, ","); this_opt;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
570 this_opt = strtok (NULL, ",")) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
571 if (!strncmp (this_opt, "font:", 5)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
572 char *p;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
573 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
574
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
575 p = this_opt + 5;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
576 for (i=0; i<sizeof (fontname) - 1; i++)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
577 if (!*p || *p == ' ' || *p == ',')
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
578 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
579 memcpy(fontname, this_opt + 5, i);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
580 } else if (!strncmp(this_opt, "noaccel", 7)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
581 noaccel = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
582 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
583 else mode_option = this_opt;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
584 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
585
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
586 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
587 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
588
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
589 #ifdef MODULE
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
590 module_init(radeonfb_init);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
591 module_exit(radeonfb_exit);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
592 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
593
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
594
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
595 MODULE_AUTHOR("Ani Joshi");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
596 MODULE_DESCRIPTION("framebuffer driver for ATI Radeon chipset");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
597
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
598
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
599
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
600 static int radeonfb_pci_register (struct pci_dev *pdev,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
601 const struct pci_device_id *ent)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
602 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
603 struct radeonfb_info *rinfo;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
604 u32 tmp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
605 int i, j;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
606 char *bios_seg = NULL;
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 rinfo = kmalloc (sizeof (struct radeonfb_info), GFP_KERNEL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
609 if (!rinfo) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
610 printk ("radeonfb: could not allocate memory\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
611 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
612 }
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 memset (rinfo, 0, sizeof (struct radeonfb_info));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
615
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
616 /* enable device */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
617 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
618 int err;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
619
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
620 if ((err = pci_enable_device(pdev))) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
621 printk("radeonfb: cannot enable device\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
622 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
623 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
624 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
625 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
626
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
627 /* set base addrs */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
628 rinfo->fb_base_phys = pci_resource_start (pdev, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
629 rinfo->mmio_base_phys = pci_resource_start (pdev, 2);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
630
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
631 /* request the mem regions */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
632 if (!request_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
633 pci_resource_len(pdev, 0), "radeonfb")) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
634 printk ("radeonfb: cannot reserve FB region\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
635 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
636 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
637 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
638
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
639 if (!request_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
640 pci_resource_len(pdev, 2), "radeonfb")) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
641 printk ("radeonfb: cannot reserve MMIO region\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
642 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
643 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
644 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
645 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
646 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
647
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
648 /* map the regions */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
649 rinfo->mmio_base = (u32) ioremap (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
650 RADEON_REGSIZE);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
651 if (!rinfo->mmio_base) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
652 printk ("radeonfb: cannot map MMIO\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
653 release_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
654 pci_resource_len(pdev, 2));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
655 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
656 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
657 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
658 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
659 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
660
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
661 /* chipset */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
662 switch (pdev->device) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
663 case PCI_DEVICE_ID_RADEON_QD:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
664 strcpy(rinfo->name, "Radeon QD ");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
665 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
666 case PCI_DEVICE_ID_RADEON_QE:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
667 strcpy(rinfo->name, "Radeon QE ");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
668 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
669 case PCI_DEVICE_ID_RADEON_QF:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
670 strcpy(rinfo->name, "Radeon QF ");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
671 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
672 case PCI_DEVICE_ID_RADEON_QG:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
673 strcpy(rinfo->name, "Radeon QG ");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
674 break;
1913
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
675 case PCI_DEVICE_ID_RADEON_QY:
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
676 strcpy(rinfo->name, "Radeon VE QY");
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
677 break;
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
678 case PCI_DEVICE_ID_RADEON_QZ:
717f46012fce Radeon VE QZ support
nick
parents: 1912
diff changeset
679 strcpy(rinfo->name, "Radeon VE QZ");
1912
33afcb62fc64 Radeon VE support
nick
parents: 1911
diff changeset
680 break;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
681 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
682 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
683 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
684
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
685 /* framebuffer size */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
686 tmp = INREG(CONFIG_MEMSIZE);
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 /* 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
689 rinfo->video_ram = tmp & CONFIG_MEMSIZE_MASK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
690
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
691 /* ram type */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
692 tmp = INREG(MEM_SDRAM_MODE_REG);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
693 switch ((MEM_CFG_TYPE & tmp) >> 30) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
694 case 0:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
695 /* SDR SGRAM (2:1) */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
696 strcpy(rinfo->ram_type, "SDR SGRAM");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
697 rinfo->ram.ml = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
698 rinfo->ram.mb = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
699 rinfo->ram.trcd = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
700 rinfo->ram.trp = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
701 rinfo->ram.twr = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
702 rinfo->ram.cl = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
703 rinfo->ram.loop_latency = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
704 rinfo->ram.rloop = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
705
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
706 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
707 case 1:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
708 /* DDR SGRAM */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
709 strcpy(rinfo->ram_type, "DDR SGRAM");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
710 rinfo->ram.ml = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
711 rinfo->ram.mb = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
712 rinfo->ram.trcd = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
713 rinfo->ram.trp = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
714 rinfo->ram.twr = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
715 rinfo->ram.cl = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
716 rinfo->ram.tr2w = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
717 rinfo->ram.loop_latency = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
718 rinfo->ram.rloop = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
719
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
720 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
721 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
722 /* 64-bit SDR SGRAM */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
723 strcpy(rinfo->ram_type, "SDR SGRAM 64");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
724 rinfo->ram.ml = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
725 rinfo->ram.mb = 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
726 rinfo->ram.trcd = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
727 rinfo->ram.trp = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
728 rinfo->ram.twr = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
729 rinfo->ram.cl = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
730 rinfo->ram.tr2w = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
731 rinfo->ram.loop_latency = 17;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
732 rinfo->ram.rloop = 17;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
733
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
734 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
735 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
736
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
737 bios_seg = radeon_find_rom(rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
738 radeon_get_pllinfo(rinfo, bios_seg);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
739
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
740 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
741 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
742
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
743 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
744
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
745 rinfo->fb_base = (u32) ioremap (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
746 rinfo->video_ram);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
747 if (!rinfo->fb_base) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
748 printk ("radeonfb: cannot map FB\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
749 iounmap ((void*)rinfo->mmio_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
750 release_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
751 pci_resource_len(pdev, 2));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
752 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
753 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
754 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
755 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
756 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
757
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
758 /* 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
759 noaccel = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
760
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
761 /* set all the vital stuff */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
762 radeon_set_fbinfo (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
763
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
764 /* 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
765 * so we can restore this upon __exit
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
766 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
767 radeon_save_state (rinfo, &rinfo->init_state);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
768
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
769 /* init palette */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
770 for (i=0; i<16; i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
771 j = color_table[i];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
772 rinfo->palette[i].red = default_red[j];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
773 rinfo->palette[i].green = default_grn[j];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
774 rinfo->palette[i].blue = default_blu[j];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
775 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
776
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
777 pdev->driver_data = rinfo;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
778
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
779 if (register_framebuffer ((struct fb_info *) rinfo) < 0) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
780 printk ("radeonfb: could not register framebuffer\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
781 iounmap ((void*)rinfo->fb_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
782 iounmap ((void*)rinfo->mmio_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
783 release_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
784 pci_resource_len(pdev, 2));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
785 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
786 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
787 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
788 return -ENODEV;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
789 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
790
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
791 if (!noaccel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
792 /* initialize the engine */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
793 radeon_engine_init (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
794 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
795
1912
33afcb62fc64 Radeon VE support
nick
parents: 1911
diff changeset
796 printk ("radeonfb: ATI %s %d MB\n", rinfo->name,
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
797 (rinfo->video_ram/(1024*1024)));
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 return 0;
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
802
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
803
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
804 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
805 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
806 struct radeonfb_info *rinfo = pdev->driver_data;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
807
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
808 if (!rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
809 return;
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 /* restore original state */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
812 radeon_write_mode (rinfo, &rinfo->init_state);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
813
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
814 unregister_framebuffer ((struct fb_info *) rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
815
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
816 iounmap ((void*)rinfo->mmio_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
817 iounmap ((void*)rinfo->fb_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
818
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
819 release_mem_region (rinfo->mmio_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
820 pci_resource_len(pdev, 2));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
821 release_mem_region (rinfo->fb_base_phys,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
822 pci_resource_len(pdev, 0));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
823
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
824 kfree (rinfo);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
825 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
826
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
827
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
828
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
829 static char *radeon_find_rom(struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
830 {
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
831 #if defined(__i386__)
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
832 u32 segstart;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
833 char *rom_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
834 char *rom;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
835 int stage;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
836 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
837 char aty_rom_sig[] = "761295520";
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
838 char radeon_sig[] = "RG6";
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 for(segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
841 stage = 1;
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 rom_base = (char *)ioremap(segstart, 0x1000);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
844
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
845 if ((*rom_base == 0x55) && (((*(rom_base + 1)) & 0xff) == 0xaa))
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
846 stage = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
847
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
848
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
849 if (stage != 2) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
850 iounmap(rom_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
851 continue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
852 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
853
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
854 rom = rom_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
855
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
856 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
857 if (aty_rom_sig[0] == *rom)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
858 if (strncmp(aty_rom_sig, rom,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
859 strlen(aty_rom_sig)) == 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
860 stage = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
861 rom++;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
862 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
863 if (stage != 3) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
864 iounmap(rom_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
865 continue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
866 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
867 rom = rom_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
868
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
869 for (i = 0; (i < 512) && (stage != 4); i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
870 if (radeon_sig[0] == *rom)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
871 if (strncmp(radeon_sig, rom,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
872 strlen(radeon_sig)) == 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
873 stage = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
874 rom++;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
875 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
876 if (stage != 4) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
877 iounmap(rom_base);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
878 continue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
879 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
880
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
881 return rom_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
882 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
883 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
884 return NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
885 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
886
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
887
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
888
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
889 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
890 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
891 void *bios_header;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
892 void *header_ptr;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
893 u16 bios_header_offset, pll_info_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
894 PLL_BLOCK pll;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
895
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
896 if (bios_seg) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
897 bios_header = bios_seg + 0x48L;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
898 header_ptr = bios_header;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
899
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
900 bios_header_offset = readw(header_ptr);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
901 bios_header = bios_seg + bios_header_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
902 bios_header += 0x30;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
903
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
904 header_ptr = bios_header;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
905 pll_info_offset = readw(header_ptr);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
906 header_ptr = bios_seg + pll_info_offset;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
907
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
908 memcpy_fromio(&pll, header_ptr, 50);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
909
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
910 rinfo->pll.xclk = (u32)pll.XCLK;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
911 rinfo->pll.ref_clk = (u32)pll.PCLK_ref_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
912 rinfo->pll.ref_div = (u32)pll.PCLK_ref_divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
913 rinfo->pll.ppll_min = pll.PCLK_min_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
914 rinfo->pll.ppll_max = pll.PCLK_max_freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
915 } else {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
916 /* no BIOS or BIOS not found, use defaults */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
917
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
918 rinfo->pll.ppll_max = 35000;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
919 rinfo->pll.ppll_min = 12000;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
920 rinfo->pll.xclk = 16600;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
921 rinfo->pll.ref_div = 67;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
922 rinfo->pll.ref_clk = 2700;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
923 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
924 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
925
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
926 static void radeon_engine_init (struct radeonfb_info *rinfo)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
927 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
928 u32 temp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
929
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
930 /* disable 3D engine */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
931 OUTREG(RB3D_CNTL, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
932
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
933 radeon_engine_reset ();
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
934
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
935 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
936 OUTREG(DSTCACHE_MODE, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
937
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
938 /* XXX */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
939 rinfo->pitch = ((rinfo->xres * (rinfo->depth / 8) + 0x3f)) >> 6;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
940
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
941 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
942 temp = INREG(DEFAULT_PITCH_OFFSET);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
943 OUTREG(DEFAULT_PITCH_OFFSET, ((temp & 0xc0000000) |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
944 (rinfo->pitch << 0x16)));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
945
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
946 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
947 OUTREGP(DP_DATATYPE, 0, ~HOST_BIG_ENDIAN_EN);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
948
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
949 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
950 OUTREG(DEFAULT_SC_BOTTOM_RIGHT, (DEFAULT_SC_RIGHT_MAX |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
951 DEFAULT_SC_BOTTOM_MAX));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
952
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
953 temp = radeon_get_dstbpp(rinfo->depth);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
954 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
955 radeon_fifo_wait (1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
956 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
957 GMC_BRUSH_SOLID_COLOR |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
958 GMC_SRC_DATATYPE_COLOR));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
959
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
960 radeon_fifo_wait (7);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
961
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
962 /* clear line drawing regs */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
963 OUTREG(DST_LINE_START, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
964 OUTREG(DST_LINE_END, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
965
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
966 /* set brush color regs */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
967 OUTREG(DP_BRUSH_FRGD_CLR, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
968 OUTREG(DP_BRUSH_BKGD_CLR, 0x00000000);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
969
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
970 /* set source color regs */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
971 OUTREG(DP_SRC_FRGD_CLR, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
972 OUTREG(DP_SRC_BKGD_CLR, 0x00000000);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
973
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
974 /* default write mask */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
975 OUTREG(DP_WRITE_MSK, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
976
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
977 radeon_engine_idle ();
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
978 }
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
981
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
982 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
983 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
984 struct fb_info *info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
985
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
986 info = &rinfo->info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
987
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
988 strcpy (info->modename, rinfo->name);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
989 info->node = -1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
990 info->flags = FBINFO_FLAG_DEFAULT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
991 info->fbops = &radeon_fb_ops;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
992 info->display_fg = NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
993 strncpy (info->fontname, fontname, sizeof (info->fontname));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
994 info->fontname[sizeof (info->fontname) - 1] = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
995 info->changevar = NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
996 info->switch_con = radeonfb_switch;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
997 info->updatevar = radeonfb_updatevar;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
998 info->blank = radeonfb_blank;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
999
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1000 if (radeon_init_disp (rinfo) < 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1001 return -1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1002
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1003 return 0;
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1007
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1008 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
1009 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1010 struct fb_info *info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1011 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1012
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1013 info = &rinfo->info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1014 disp = &rinfo->disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1015
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1016 disp->var = radeonfb_default_var;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1017 info->disp = disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1018
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1019 radeon_set_dispsw (rinfo, disp);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1020
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1021 if (noaccel)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1022 disp->scrollmode = SCROLL_YREDRAW;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1023 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1024 disp->scrollmode = 0;
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 rinfo->currcon_display = disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1027
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1028 if ((radeon_init_disp_var (rinfo)) < 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1029 return -1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1030
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1031 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1032 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1033
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1034
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1035
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1036 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
1037 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1038 #ifndef MODULE
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1039 if (mode_option)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1040 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
1041 NULL, 0, NULL, 8);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1042 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1043 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1044 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
1045 NULL, 0, NULL, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1046
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1047 if (noaccel)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1048 rinfo->disp.var.accel_flags &= ~FB_ACCELF_TEXT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1049 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1050 rinfo->disp.var.accel_flags |= FB_ACCELF_TEXT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1051
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1052 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1053 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1054
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1055
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1056 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
1057 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1058 int accel;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1059
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1060 accel = disp->var.accel_flags & FB_ACCELF_TEXT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1061
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1062 disp->dispsw_data = NULL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1063
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1064 disp->screen_base = (char*)rinfo->fb_base;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1065 disp->type = FB_TYPE_PACKED_PIXELS;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1066 disp->type_aux = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1067 disp->ypanstep = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1068 disp->ywrapstep = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1069 disp->can_soft_blank = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1070 disp->inverse = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1071
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1072 rinfo->depth = disp->var.bits_per_pixel;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1073 switch (disp->var.bits_per_pixel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1074 #ifdef FBCON_HAS_CFB8
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1075 case 8:
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1076 disp->dispsw = &fbcon_cfb8;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1077 disp->visual = FB_VISUAL_PSEUDOCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1078 disp->line_length = disp->var.xres_virtual;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1079 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1080 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1081 #ifdef FBCON_HAS_CFB16
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1082 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1083 disp->dispsw = &fbcon_cfb16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1084 disp->dispsw_data = &rinfo->con_cmap.cfb16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1085 disp->visual = FB_VISUAL_DIRECTCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1086 disp->line_length = disp->var.xres_virtual * 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1087 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1088 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1089 #ifdef FBCON_HAS_CFB32
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1090 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1091 disp->dispsw = &fbcon_cfb24;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1092 disp->dispsw_data = &rinfo->con_cmap.cfb24;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1093 disp->visual = FB_VISUAL_DIRECTCOLOR;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1094 disp->line_length = disp->var.xres_virtual * 4;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1095 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1096 #endif
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1097 #ifdef FBCON_HAS_CFB32
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1098 case 32:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1099 disp->dispsw = &fbcon_cfb32;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1100 disp->dispsw_data = &rinfo->con_cmap.cfb32;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1101 disp->visual = FB_VISUAL_DIRECTCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1102 disp->line_length = disp->var.xres_virtual * 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1103 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1104 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1105 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1106 printk ("radeonfb: setting fbcon_dummy renderer\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1107 disp->dispsw = &fbcon_dummy;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1108 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1109
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1110 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1111 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1112
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1113
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1114
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1115 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1116 * fb ops
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1117 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1118
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1119 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
1120 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1121 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1122 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1123 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1124
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1125 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1126
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1127 memset (fix, 0, sizeof (struct fb_fix_screeninfo));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1128 strcpy (fix->id, rinfo->name);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1129
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1130 fix->smem_start = rinfo->fb_base_phys;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1131 fix->smem_len = rinfo->video_ram;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1132
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1133 fix->type = disp->type;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1134 fix->type_aux = disp->type_aux;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1135 fix->visual = disp->visual;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1136
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1137 fix->xpanstep = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1138 fix->ypanstep = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1139 fix->ywrapstep = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1140
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1141 fix->line_length = disp->line_length;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1142
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1143 fix->mmio_start = rinfo->mmio_base_phys;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1144 fix->mmio_len = RADEON_REGSIZE;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1145 if (noaccel)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1146 fix->accel = FB_ACCEL_NONE;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1147 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1148 fix->accel = 40; /* XXX */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1149
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1150 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1151 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1152
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1153
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1154
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1155 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
1156 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1157 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1158 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1159
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1160 *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
1161
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1162 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1163 }
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1166
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1167 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
1168 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1169 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1170 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1171 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1172 struct fb_var_screeninfo v;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1173 int nom, den, accel;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1174 unsigned chgvar = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1175
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1176 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1177
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1178 accel = var->accel_flags & FB_ACCELF_TEXT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1179
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1180 if (con >= 0) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1181 chgvar = ((disp->var.xres != var->xres) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1182 (disp->var.yres != var->yres) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1183 (disp->var.xres_virtual != var->xres_virtual) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1184 (disp->var.yres_virtual != var->yres_virtual) ||
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1185 (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
1186 memcmp (&disp->var.red, &var->red, sizeof (var->red)) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1187 memcmp (&disp->var.green, &var->green, sizeof (var->green)) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1188 memcmp (&disp->var.blue, &var->blue, sizeof (var->blue)));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1189 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1190
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1191 memcpy (&v, var, sizeof (v));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1192
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1193 switch (v.bits_per_pixel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1194 #ifdef FBCON_HAS_CFB8
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1195 case 8:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1196 nom = den = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1197 disp->line_length = v.xres_virtual;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1198 disp->visual = FB_VISUAL_PSEUDOCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1199 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
1200 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
1201 v.transp.offset = v.transp.length = 0;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1202 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1203 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1204
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1205 #ifdef FBCON_HAS_CFB16
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1206 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1207 nom = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1208 den = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1209 disp->line_length = v.xres_virtual * 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1210 disp->visual = FB_VISUAL_DIRECTCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1211 v.red.offset = 11;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1212 v.green.offset = 5;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1213 v.blue.offset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1214 v.red.length = 5;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1215 v.green.length = 6;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1216 v.blue.length = 5;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1217 v.transp.offset = v.transp.length = 0;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1218 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1219 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1220
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1221 #ifdef FBCON_HAS_CFB24
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1222 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1223 nom = 4;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1224 den = 1;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1225 disp->line_length = v.xres_virtual * 3;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1226 disp->visual = FB_VISUAL_DIRECTCOLOR;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1227 v.red.offset = 16;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1228 v.green.offset = 8;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1229 v.blue.offset = 0;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1230 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
1231 v.transp.offset = v.transp.length = 0;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1232 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1233 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1234 #ifdef FBCON_HAS_CFB32
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1235 case 32:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1236 nom = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1237 den = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1238 disp->line_length = v.xres_virtual * 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1239 disp->visual = FB_VISUAL_DIRECTCOLOR;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1240 v.red.offset = 16;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1241 v.green.offset = 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1242 v.blue.offset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1243 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
1244 v.transp.offset = 24;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1245 v.transp.length = 8;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1246 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1247 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1248 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1249 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
1250 var->xres, var->yres, var->bits_per_pixel);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1251 return -EINVAL;
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
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1254 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
1255 return -EINVAL;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1256
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1257 if (v.xoffset < 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1258 v.xoffset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1259 if (v.yoffset < 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1260 v.yoffset = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1261
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1262 if (v.xoffset > v.xres_virtual - v.xres)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1263 v.xoffset = v.xres_virtual - v.xres - 1;
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 if (v.yoffset > v.yres_virtual - v.yres)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1266 v.yoffset = v.yres_virtual - v.yres - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1267
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1268 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
1269 v.transp.offset = v.transp.length =
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1270 v.transp.msb_right = 0;
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 switch (v.activate & FB_ACTIVATE_MASK) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1273 case FB_ACTIVATE_TEST:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1274 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1275 case FB_ACTIVATE_NXTOPEN:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1276 case FB_ACTIVATE_NOW:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1277 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1278 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1279 return -EINVAL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1280 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1281
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1282 memcpy (&disp->var, &v, sizeof (v));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1283
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1284 if (chgvar) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1285 radeon_set_dispsw(rinfo, disp);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1286
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1287 if (noaccel)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1288 disp->scrollmode = SCROLL_YREDRAW;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1289 else
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1290 disp->scrollmode = 0;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1291
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1292 if (info && info->changevar)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1293 info->changevar(con);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1294 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1295
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1296 radeon_load_video_mode (rinfo, &v);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1297
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1298 do_install_cmap(con, info);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1299
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1300 return 0;
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
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 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
1306 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1307 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1308 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1309 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1310
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1311 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1312
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1313 if (con == rinfo->currcon) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1314 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
1315 return rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1316 } else if (disp->cmap.len)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1317 fb_copy_cmap (&disp->cmap, cmap, kspc ? 0 : 2);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1318 else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1319 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
1320 cmap, kspc ? 0 : 2);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1321
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1322 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1323 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1324
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1325
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1326
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1327 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
1328 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1329 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1330 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1331 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1332 unsigned int cmap_len;
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 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
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 cmap_len = radeon_get_cmap_len (&disp->var);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1337 if (disp->cmap.len != cmap_len) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1338 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
1339 if (err)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1340 return err;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1341 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1342
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1343 if (con == rinfo->currcon) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1344 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
1345 return rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1346 } else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1347 fb_copy_cmap (cmap, &disp->cmap, kspc ? 0 : 1);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1348
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1349 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1350 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1351
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1352
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1353
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1354 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
1355 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1356 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1357 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1358 u32 offset, xoffset, yoffset;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1359
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1360 xoffset = (var->xoffset + 7) & ~7;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1361 yoffset = var->yoffset;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1362
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1363 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
1364 var->yres_virtual))
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1365 return -EINVAL;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1366
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1367 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
1368
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1369 OUTREG(CRTC_OFFSET, offset);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1370
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1371 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1372 }
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
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1375 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
1376 {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1377 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1378
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1379 if (con != rinfo->currcon)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1380 return;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1381
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1382 if (fb_display[con].cmap.len)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1383 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
1384 else {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1385 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
1386 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
1387 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1388 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1389
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1390
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1391 static int radeonfb_do_maximize(struct radeonfb_info *rinfo,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1392 struct fb_var_screeninfo *var,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1393 struct fb_var_screeninfo *v,
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1394 int nom, int den)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1395 {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1396 static struct {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1397 int xres, yres;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1398 } modes[] = {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1399 {1600, 1280},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1400 {1280, 1024},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1401 {1024, 768},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1402 {800, 600},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1403 {640, 480},
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1404 {-1, -1}
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1405 };
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1406 int i;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1407
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1408 /* use highest possible virtual resolution */
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1409 if (v->xres_virtual == -1 && v->yres_virtual == -1) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1410 printk("radeonfb: using max availabe virtual resolution\n");
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1411 for (i=0; modes[i].xres != -1; i++) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1412 if (modes[i].xres * nom / den * modes[i].yres <
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1413 rinfo->video_ram / 2)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1414 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1415 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1416 if (modes[i].xres == -1) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1417 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
1418 return -EINVAL;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1419 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1420 v->xres_virtual = modes[i].xres;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1421 v->yres_virtual = modes[i].yres;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1422
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1423 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
1424 v->xres_virtual, v->yres_virtual);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1425 } else if (v->xres_virtual == -1) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1426 v->xres_virtual = (rinfo->video_ram * den /
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1427 (nom * v->yres_virtual * 2)) & ~15;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1428 } else if (v->yres_virtual == -1) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1429 v->xres_virtual = (v->xres_virtual + 15) & ~15;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1430 v->yres_virtual = rinfo->video_ram * den /
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1431 (nom * v->xres_virtual *2);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1432 } else {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1433 if (v->xres_virtual * nom / den * v->yres_virtual >
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1434 rinfo->video_ram) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1435 return -EINVAL;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1436 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1437 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1438
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1439 if (v->xres_virtual * nom / den >= 8192) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1440 v->xres_virtual = 8192 * den / nom - 16;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1441 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1442
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1443 if (v->xres_virtual < v->xres)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1444 return -EINVAL;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1445
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1446 if (v->yres_virtual < v->yres)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1447 return -EINVAL;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1448
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1449 return 0;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1450 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1451
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1452
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1453 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
1454 unsigned long arg, int con, struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1455 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1456 return -EINVAL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1457 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1458
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1459
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1460
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1461 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
1462 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1463 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1464 struct display *disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1465 struct fb_cmap *cmap;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1466 int switchcon = 0;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1467
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1468 disp = (con < 0) ? rinfo->info.disp : &fb_display[con];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1469
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1470 if (rinfo->currcon >= 0) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1471 cmap = &(rinfo->currcon_display->cmap);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1472 if (cmap->len)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1473 fb_get_cmap (cmap, 1, radeon_getcolreg, info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1474 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1475
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1476 if ((disp->var.xres != rinfo->xres) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1477 (disp->var.yres != rinfo->yres) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1478 (disp->var.pixclock != rinfo->pixclock) ||
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1479 (disp->var.bits_per_pixel != rinfo->depth))
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1480 switchcon = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1481
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1482 if (switchcon) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1483 rinfo->currcon = con;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1484 rinfo->currcon_display = disp;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1485 disp->var.activate = FB_ACTIVATE_NOW;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1486
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1487 radeonfb_set_var (&disp->var, con, info);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1488 radeon_set_dispsw (rinfo, disp);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1489 do_install_cmap(con, info);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1490 }
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1491
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1492 /* XXX absurd hack for X to restore console */
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1493 {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1494 OUTREG(CRTC_EXT_CNTL, rinfo->hack_crtc_ext_cntl);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1495 OUTREG(CRTC_V_SYNC_STRT_WID, rinfo->hack_crtc_v_sync_strt_wid);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1496 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1497
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1498 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1499 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1500
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1501
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1502
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1503 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
1504 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1505 int rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1506
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1507 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
1508 con, info);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1509
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1510 return rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1511 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1512
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1513 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
1514 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1515 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1516 u32 val = INREG(CRTC_EXT_CNTL);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1517
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1518 /* reset it */
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1519 val &= ~(CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS |
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1520 CRTC_VSYNC_DIS);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1521
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1522 switch (blank) {
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1523 case VESA_NO_BLANKING:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1524 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1525 case VESA_VSYNC_SUSPEND:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1526 val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1527 break;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1528 case VESA_HSYNC_SUSPEND:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1529 val |= (CRTC_DISPLAY_DIS | CRTC_HSYNC_DIS);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1530 break;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1531 case VESA_POWERDOWN:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1532 val |= (CRTC_DISPLAY_DIS | CRTC_VSYNC_DIS |
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1533 CRTC_HSYNC_DIS);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1534 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1535 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1536
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1537 OUTREG(CRTC_EXT_CNTL, val);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1538 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1539
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1540
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1541
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1542 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
1543 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1544 int rc = 16; /* reasonable default */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1545
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1546 switch (var->bits_per_pixel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1547 case 8:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1548 rc = 256;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1549 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1550 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1551 rc = 64;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1552 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1553 default:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1554 rc = 32;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1555 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1556 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1557
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1558 return rc;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1559 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1560
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1561
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1562
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1563 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
1564 unsigned *blue, unsigned *transp,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1565 struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1566 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1567 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1568
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1569 if (regno > 255)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1570 return 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1571
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1572 *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
1573 *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
1574 *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
1575 *transp = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1576
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1577 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1578 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1579
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1580
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1581
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1582 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
1583 unsigned blue, unsigned transp, struct fb_info *info)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1584 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1585 struct radeonfb_info *rinfo = (struct radeonfb_info *) info;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1586 u32 pindex;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1587
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1588 if (regno > 255)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1589 return 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1590
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1591 red >>= 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1592 green >>= 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1593 blue >>= 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1594 rinfo->palette[regno].red = red;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1595 rinfo->palette[regno].green = green;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1596 rinfo->palette[regno].blue = blue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1597
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1598 /* init gamma for hicolor */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1599 if ((rinfo->depth > 8) && (regno == 0)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1600 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1601
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1602 for (i=0; i<255; i++) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1603 OUTREG(PALETTE_INDEX, i);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1604 OUTREG(PALETTE_DATA, (i << 16) | (i << 8) | i);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1605 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1606 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1607
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1608 /* default */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1609 pindex = regno;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1610
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1611 /* XXX actually bpp, fixme */
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1612 if (rinfo->depth == 16)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1613 pindex = regno * 8;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1614
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1615 if (rinfo->depth == 16) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1616 OUTREG(PALETTE_INDEX, pindex/2);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1617 OUTREG(PALETTE_DATA, (rinfo->palette[regno/2].red << 16) |
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1618 (green << 8) | (rinfo->palette[regno/2].blue));
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1619 green = rinfo->palette[regno/2].green;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1620 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1621
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1622 if ((rinfo->depth == 8) || (regno < 32)) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1623 OUTREG(PALETTE_INDEX, pindex);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1624 OUTREG(PALETTE_DATA, (red << 16) | (green << 8) | blue);
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1625 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1626
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1627 #if 0
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1628 col = (red << 16) | (green << 8) | blue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1629
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1630 if (rinfo->depth == 16) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1631 pindex = regno << 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1632
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1633 if ((rinfo->depth == 16) && (regno >= 32)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1634 pindex -= 252;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1635
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1636 col = (rinfo->palette[regno >> 1].red << 16) |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1637 (green << 8) |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1638 (rinfo->palette[regno >> 1].blue);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1639 } else {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1640 col = (red << 16) | (green << 8) | blue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1641 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1642 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1643
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1644 OUTREG8(PALETTE_INDEX, pindex);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1645 radeon_fifo_wait(32);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1646 OUTREG(PALETTE_DATA, col);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1647 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1648
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1649 #if defined(FBCON_HAS_CFB16) || defined(FBCON_HAS_CFB32)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1650 if (regno < 32) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1651 switch (rinfo->depth) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1652 #ifdef FBCON_HAS_CFB16
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1653 case 16:
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1654 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
1655 regno;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1656 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1657 #endif
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1658 #ifdef FBCON_HAS_CFB24
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1659 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1660 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
1661 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1662 #endif
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1663 #ifdef FBCON_HAS_CFB32
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1664 case 32: {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1665 u32 i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1666
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1667 i = (regno << 8) | regno;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1668 rinfo->con_cmap.cfb32[regno] = (i << 16) | i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1669 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1670 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1671 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1672 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1673 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1674 #endif
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1675 return 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1676 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1677
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1678
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1679
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1680 static void radeon_save_state (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1681 struct radeon_regs *save)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1682 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1683 save->crtc_gen_cntl = INREG(CRTC_GEN_CNTL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1684 save->crtc_ext_cntl = INREG(CRTC_EXT_CNTL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1685 save->dac_cntl = INREG(DAC_CNTL);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1686 save->crtc_h_total_disp = INREG(CRTC_H_TOTAL_DISP);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1687 save->crtc_h_sync_strt_wid = INREG(CRTC_H_SYNC_STRT_WID);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1688 save->crtc_v_total_disp = INREG(CRTC_V_TOTAL_DISP);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1689 save->crtc_v_sync_strt_wid = INREG(CRTC_V_SYNC_STRT_WID);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1690 save->crtc_pitch = INREG(CRTC_PITCH);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1691 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1692
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1693
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1694
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1695 static void radeon_load_video_mode (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1696 struct fb_var_screeninfo *mode)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1697 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1698 struct radeon_regs newmode;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1699 int hTotal, vTotal, hSyncStart, hSyncEnd,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1700 hSyncPol, vSyncStart, vSyncEnd, vSyncPol, cSync;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1701 u8 hsync_adj_tab[] = {0, 0x12, 9, 9, 6, 5};
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1702 u32 dotClock = 1000000000 / mode->pixclock,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1703 sync, h_sync_pol, v_sync_pol;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1704 int freq = dotClock / 10; /* x 100 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1705 int xclk_freq, vclk_freq, xclk_per_trans, xclk_per_trans_precise;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1706 int useable_precision, roff, ron;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1707 int min_bits, format = 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1708 int hsync_start, hsync_fudge, bytpp, hsync_wid, vsync_wid;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1709
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1710 rinfo->xres = mode->xres;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1711 rinfo->yres = mode->yres;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1712 rinfo->pixclock = mode->pixclock;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1713
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1714 hSyncStart = mode->xres + mode->right_margin;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1715 hSyncEnd = hSyncStart + mode->hsync_len;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1716 hTotal = hSyncEnd + mode->left_margin;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1717
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1718 vSyncStart = mode->yres + mode->lower_margin;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1719 vSyncEnd = vSyncStart + mode->vsync_len;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1720 vTotal = vSyncEnd + mode->upper_margin;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1721
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1722 sync = mode->sync;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1723 h_sync_pol = sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1724 v_sync_pol = sync & FB_SYNC_VERT_HIGH_ACT ? 0 : 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1725
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1726 RTRACE("hStart = %d, hEnd = %d, hTotal = %d\n",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1727 hSyncStart, hSyncEnd, hTotal);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1728 RTRACE("vStart = %d, vEnd = %d, vTotal = %d\n",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1729 vSyncStart, vSyncEnd, vTotal);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1730
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1731 hsync_wid = (hSyncEnd - hSyncStart) / 8;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1732 vsync_wid = vSyncEnd - vSyncStart;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1733 if (hsync_wid == 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1734 hsync_wid = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1735 else if (hsync_wid > 0x3f) /* max */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1736 hsync_wid = 0x3f;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1737 vsync_wid = mode->vsync_len;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1738 if (vsync_wid == 0)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1739 vsync_wid = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1740 else if (vsync_wid > 0x1f) /* max */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1741 vsync_wid = 0x1f;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1742
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1743 hSyncPol = mode->sync & FB_SYNC_HOR_HIGH_ACT ? 0 : 1;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1744 vSyncPol = mode->sync & FB_SYNC_VERT_HIGH_ACT ? 0 : 1;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1745
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1746 cSync = mode->sync & FB_SYNC_COMP_HIGH_ACT ? (1 << 4) : 0;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1747
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1748 switch (mode->bits_per_pixel) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1749 case 8:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1750 format = DST_8BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1751 bytpp = 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1752 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1753 case 16:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1754 format = DST_16BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1755 bytpp = 2;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1756 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1757 case 24:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1758 format = DST_24BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1759 bytpp = 3;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1760 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1761 case 32:
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1762 format = DST_32BPP;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1763 bytpp = 4;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1764 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1765 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1766
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1767 hsync_fudge = hsync_adj_tab[format-1];
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1768 hsync_start = hSyncStart - 8 + hsync_fudge;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1769
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1770 newmode.crtc_gen_cntl = CRTC_EXT_DISP_EN | CRTC_EN |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1771 (format << 8);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1772
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1773 newmode.crtc_ext_cntl = VGA_ATI_LINEAR | XCRT_CNT_EN;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1774
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1775 newmode.dac_cntl = INREG(DAC_CNTL) | DAC_MASK_ALL | DAC_VGA_ADR_EN |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1776 DAC_8BIT_EN;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1777
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1778 newmode.crtc_h_total_disp = ((((hTotal / 8) - 1) & 0xffff) |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1779 (((mode->xres / 8) - 1) << 16));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1780
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1781 newmode.crtc_h_sync_strt_wid = ((hsync_start & 0x1fff) |
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1782 (hsync_wid << 16) | (h_sync_pol << 23));
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1783
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1784 newmode.crtc_v_total_disp = ((vTotal - 1) & 0xffff) |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1785 ((mode->yres - 1) << 16);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1786
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1787 newmode.crtc_v_sync_strt_wid = (((vSyncStart - 1) & 0xfff) |
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1788 (vsync_wid << 16) | (v_sync_pol << 23));
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1789
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1790 newmode.crtc_pitch = (mode->xres >> 3);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1791
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1792 newmode.surface_cntl = SURF_TRANSLATION_DIS;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1793 #if defined(__BIG_ENDIAN)
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1794 switch (mode->bits_per_pixel) {
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1795 case 16:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1796 newmode.surface_cntl |= NONSURF_AP0_SWP_16BPP;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1797 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1798 case 24:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1799 case 32:
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1800 newmode.surface_cntl |= NONSURF_AP0_SWP_32BPP;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1801 break;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1802 }
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1803 #endif
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1804
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1805 rinfo->pitch = ((mode->xres * ((mode->bits_per_pixel + 1) / 8) + 0x3f)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1806 & ~(0x3f)) / 64;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1807
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1808 RTRACE("h_total_disp = 0x%x\t hsync_strt_wid = 0x%x\n",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1809 newmode.crtc_h_total_disp, newmode.crtc_h_sync_strt_wid);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1810 RTRACE("v_total_disp = 0x%x\t vsync_strt_wid = 0x%x\n",
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1811 newmode.crtc_v_total_disp, newmode.crtc_v_sync_strt_wid);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1812
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1813 newmode.xres = mode->xres;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1814 newmode.yres = mode->yres;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1815
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1816 rinfo->bpp = mode->bits_per_pixel;
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1817 rinfo->hack_crtc_ext_cntl = newmode.crtc_ext_cntl;
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1818 rinfo->hack_crtc_v_sync_strt_wid = newmode.crtc_v_sync_strt_wid;
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1819
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1820 if (freq > rinfo->pll.ppll_max)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1821 freq = rinfo->pll.ppll_max;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1822 if (freq*12 < rinfo->pll.ppll_min)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1823 freq = rinfo->pll.ppll_min / 12;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1824
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1825 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1826 struct {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1827 int divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1828 int bitvalue;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1829 } *post_div,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1830 post_divs[] = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1831 { 1, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1832 { 2, 1 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1833 { 4, 2 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1834 { 8, 3 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1835 { 3, 4 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1836 { 16, 5 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1837 { 6, 6 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1838 { 12, 7 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1839 { 0, 0 },
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1840 };
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1841
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1842 for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1843 rinfo->pll_output_freq = post_div->divider * freq;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1844 if (rinfo->pll_output_freq >= rinfo->pll.ppll_min &&
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1845 rinfo->pll_output_freq <= rinfo->pll.ppll_max)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1846 break;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1847 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1848
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1849 rinfo->post_div = post_div->divider;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1850 rinfo->fb_div = round_div(rinfo->pll.ref_div*rinfo->pll_output_freq,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1851 rinfo->pll.ref_clk);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1852 newmode.ppll_ref_div = rinfo->pll.ref_div;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1853 newmode.ppll_div_3 = rinfo->fb_div | (post_div->bitvalue << 16);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1854 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1855
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1856 RTRACE("post div = 0x%x\n", rinfo->post_div);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1857 RTRACE("fb_div = 0x%x\n", rinfo->fb_div);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1858 RTRACE("ppll_div_3 = 0x%x\n", newmode.ppll_div_3);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1859
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1860 /* DDA */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1861 vclk_freq = round_div(rinfo->pll.ref_clk * rinfo->fb_div,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1862 rinfo->pll.ref_div * rinfo->post_div);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1863 xclk_freq = rinfo->pll.xclk;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1864
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1865 xclk_per_trans = round_div(xclk_freq * 128, vclk_freq * mode->bits_per_pixel);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1866
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1867 min_bits = min_bits_req(xclk_per_trans);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1868 useable_precision = min_bits + 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1869
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1870 xclk_per_trans_precise = round_div((xclk_freq * 128) << (11 - useable_precision),
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1871 vclk_freq * mode->bits_per_pixel);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1872
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1873 ron = (4 * rinfo->ram.mb + 3 * _max(rinfo->ram.trcd - 2, 0) +
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1874 2 * rinfo->ram.trp + rinfo->ram.twr + rinfo->ram.cl + rinfo->ram.tr2w +
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1875 xclk_per_trans) << (11 - useable_precision);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1876 roff = xclk_per_trans_precise * (32 - 4);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1877
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1878 RTRACE("ron = %d, roff = %d\n", ron, roff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1879 RTRACE("vclk_freq = %d, per = %d\n", vclk_freq, xclk_per_trans_precise);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1880
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1881 if ((ron + rinfo->ram.rloop) >= roff) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1882 printk("radeonfb: error ron out of range\n");
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1883 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1884 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1885
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1886 newmode.dda_config = (xclk_per_trans_precise |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1887 (useable_precision << 16) |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1888 (rinfo->ram.rloop << 20));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1889 newmode.dda_on_off = (ron << 16) | roff;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1890
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1891 /* do it! */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1892 radeon_write_mode (rinfo, &newmode);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1893
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1894 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1895 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1896
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1897
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1898
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1899 static void radeon_write_mode (struct radeonfb_info *rinfo,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1900 struct radeon_regs *mode)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1901 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1902 int i;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1903
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1904 /* blank screen */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1905 OUTREG8(CRTC_EXT_CNTL + 1, 4);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1906
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1907 for (i=0; i<9; i++)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1908 OUTREG(common_regs[i].reg, common_regs[i].val);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1909
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1910 OUTREG(CRTC_GEN_CNTL, mode->crtc_gen_cntl);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1911 OUTREGP(CRTC_EXT_CNTL, mode->crtc_ext_cntl,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1912 CRTC_HSYNC_DIS | CRTC_VSYNC_DIS | CRTC_DISPLAY_DIS);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1913 OUTREGP(DAC_CNTL, mode->dac_cntl, DAC_RANGE_CNTL | DAC_BLANKING);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1914 OUTREG(CRTC_H_TOTAL_DISP, mode->crtc_h_total_disp);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1915 OUTREG(CRTC_H_SYNC_STRT_WID, mode->crtc_h_sync_strt_wid);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1916 OUTREG(CRTC_V_TOTAL_DISP, mode->crtc_v_total_disp);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1917 OUTREG(CRTC_V_SYNC_STRT_WID, mode->crtc_v_sync_strt_wid);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1918 OUTREG(CRTC_OFFSET, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1919 OUTREG(CRTC_OFFSET_CNTL, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1920 OUTREG(CRTC_PITCH, mode->crtc_pitch);
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1921 OUTREG(SURFACE_CNTL, mode->surface_cntl);
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1922
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1923 while ((INREG(CLOCK_CNTL_INDEX) & PPLL_DIV_SEL_MASK) !=
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1924 PPLL_DIV_SEL_MASK) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1925 OUTREGP(CLOCK_CNTL_INDEX, PPLL_DIV_SEL_MASK, 0xffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1926 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1927
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1928 OUTPLLP(PPLL_CNTL, PPLL_RESET, 0xffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1929
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1930 while ((INPLL(PPLL_REF_DIV) & PPLL_REF_DIV_MASK) !=
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1931 (mode->ppll_ref_div & PPLL_REF_DIV_MASK)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1932 OUTPLLP(PPLL_REF_DIV, mode->ppll_ref_div, ~PPLL_REF_DIV_MASK);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1933 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1934
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1935 while ((INPLL(PPLL_DIV_3) & PPLL_FB3_DIV_MASK) !=
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1936 (mode->ppll_div_3 & PPLL_FB3_DIV_MASK)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1937 OUTPLLP(PPLL_DIV_3, mode->ppll_div_3, ~PPLL_FB3_DIV_MASK);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1938 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1939
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1940 while ((INPLL(PPLL_DIV_3) & PPLL_POST3_DIV_MASK) !=
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1941 (mode->ppll_div_3 & PPLL_POST3_DIV_MASK)) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1942 OUTPLLP(PPLL_DIV_3, mode->ppll_div_3, ~PPLL_POST3_DIV_MASK);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1943 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1944
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1945 OUTPLL(HTOTAL_CNTL, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1946
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1947 OUTPLLP(PPLL_CNTL, 0, ~PPLL_RESET);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1948
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1949 OUTREG(DDA_CONFIG, mode->dda_config);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1950 OUTREG(DDA_ON_OFF, mode->dda_on_off);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1951
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1952 /* unblank screen */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1953 OUTREG8(CRTC_EXT_CNTL + 1, 0);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1954
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1955 return;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1956 }
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1957
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
1958 #if 0
1911
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1959
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1960 /*
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1961 * text console acceleration
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1962 */
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1963
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1964
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1965 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
1966 int dsty, int dstx, int height, int width)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1967 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1968 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
1969 u32 dp_cntl = DST_LAST_PEL;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1970
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1971 srcx *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1972 srcy *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1973 dstx *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1974 dsty *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1975 width *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1976 height *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1977
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1978 if (srcy < dsty) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1979 srcy += height - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1980 dsty += height - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1981 } else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1982 dp_cntl |= DST_Y_TOP_TO_BOTTOM;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1983
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1984 if (srcx < dstx) {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1985 srcx += width - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1986 dstx += width - 1;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1987 } else
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1988 dp_cntl |= DST_X_LEFT_TO_RIGHT;
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1989
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1990 radeon_fifo_wait(6);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1991 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
1992 GMC_BRUSH_NONE |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1993 GMC_SRC_DATATYPE_COLOR |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1994 ROP3_S |
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1995 DP_SRC_SOURCE_MEMORY));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1996 OUTREG(DP_WRITE_MSK, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1997 OUTREG(DP_CNTL, dp_cntl);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1998 OUTREG(SRC_Y_X, (srcy << 16) | srcx);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
1999 OUTREG(DST_Y_X, (dsty << 16) | dstx);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2000 OUTREG(DST_HEIGHT_WIDTH, (height << 16) | width);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2001 }
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2004
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2005 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
2006 int srcy, int srcx, int height, int width)
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2007 {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2008 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
2009 u32 clr;
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 clr = attr_bgcol_ec(p, conp);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2012 clr |= (clr << 8);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2013 clr |= (clr << 16);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2014
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2015 srcx *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2016 srcy *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2017 width *= fontwidth(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2018 height *= fontheight(p);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2019
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2020 radeon_fifo_wait(6);
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 ROP3_P));
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2025 OUTREG(DP_BRUSH_FRGD_CLR, clr);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2026 OUTREG(DP_WRITE_MSK, 0xffffffff);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2027 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
2028 OUTREG(DST_Y_X, (srcy << 16) | srcx);
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2029 OUTREG(DST_WIDTH_HEIGHT, (width << 16) | height);
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
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2032
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2033
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 #ifdef FBCON_HAS_CFB8
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2036 static struct display_switch fbcon_radeon8 = {
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2037 setup: fbcon_cfb8_setup,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2038 bmove: fbcon_radeon_bmove,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2039 clear: fbcon_cfb8_clear,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2040 putc: fbcon_cfb8_putc,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2041 putcs: fbcon_cfb8_putcs,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2042 revc: fbcon_cfb8_revc,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2043 clear_margins: fbcon_cfb8_clear_margins,
89313cfc8fec Initial import of Ani Joshi's radeonfb-0.0.9
nick
parents:
diff changeset
2044 fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(12)|FONTWIDTH(16)
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 #endif
1914
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2047
838bfa146fa3 Merge with Ani Joshi's radeonfb-0.1.0
nick
parents: 1913
diff changeset
2048 #endif /* 0 */