This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / video / intelfb / intelfb.h
1 #ifndef _INTELFB_H
2 #define _INTELFB_H
3
4 /* $DHD: intelfb/intelfb.h,v 1.40 2003/06/27 15:06:25 dawes Exp $ */
5
6 #include <linux/agp_backend.h>
7 #include <linux/fb.h>
8
9
10 /*** Version/name ***/
11 #define INTELFB_VERSION                 "0.9.2"
12 #define INTELFB_MODULE_NAME             "intelfb"
13 #define SUPPORTED_CHIPSETS              "830M/845G/852GM/855GM/865G"
14
15
16 /*** Debug/feature defines ***/
17
18 #ifndef DEBUG
19 #define DEBUG                           0
20 #endif
21
22 #ifndef VERBOSE
23 #define VERBOSE                         0
24 #endif
25
26 #ifndef REGDUMP
27 #define REGDUMP                         0
28 #endif
29
30 #ifndef DETECT_VGA_CLASS_ONLY
31 #define DETECT_VGA_CLASS_ONLY           1
32 #endif
33
34 #ifndef ALLOCATE_FOR_PANNING
35 #define ALLOCATE_FOR_PANNING            1
36 #endif
37
38 #ifndef PREFERRED_MODE
39 #define PREFERRED_MODE                  "1024x768-16@60"
40 #endif
41
42 /*** hw-related values ***/
43
44 /* PCI ids for supported devices */
45 #define PCI_DEVICE_ID_INTEL_830M        0x3577
46 #define PCI_DEVICE_ID_INTEL_845G        0x2562
47 #define PCI_DEVICE_ID_INTEL_85XGM       0x3582
48 #define PCI_DEVICE_ID_INTEL_865G        0x2572
49
50 /* Size of MMIO region */
51 #define INTEL_REG_SIZE                  0x80000
52
53 #define STRIDE_ALIGNMENT                16
54
55 #define PALETTE_8_ENTRIES               256
56
57
58 /*** Macros ***/
59
60 /* basic arithmetic */
61 #define KB(x)                   ((x) * 1024)
62 #define MB(x)                   ((x) * 1024 * 1024)
63 #define BtoKB(x)                ((x) / 1024)
64 #define BtoMB(x)                ((x) / 1024 / 1024)
65
66 #define GTT_PAGE_SIZE           KB(4)
67
68 #define ROUND_UP_TO(x, y)       (((x) + (y) - 1) / (y) * (y))
69 #define ROUND_DOWN_TO(x, y)     ((x) / (y) * (y))
70 #define ROUND_UP_TO_PAGE(x)     ROUND_UP_TO((x), GTT_PAGE_SIZE)
71 #define ROUND_DOWN_TO_PAGE(x)   ROUND_DOWN_TO((x), GTT_PAGE_SIZE)
72
73 /* messages */
74 #define PFX                     INTELFB_MODULE_NAME ": "
75
76 #define ERR_MSG(fmt, args...)   printk(KERN_ERR PFX fmt, ## args)
77 #define WRN_MSG(fmt, args...)   printk(KERN_WARNING PFX fmt, ## args)
78 #define NOT_MSG(fmt, args...)   printk(KERN_NOTICE PFX fmt, ## args)
79 #define INF_MSG(fmt, args...)   printk(KERN_INFO PFX fmt, ## args)
80 #if DEBUG
81 #define DBG_MSG(fmt, args...)   printk(KERN_DEBUG PFX fmt, ## args)
82 #else
83 #define DBG_MSG(fmt, args...)   while (0) printk(fmt, ## args)
84 #endif
85
86 /* get commonly used pointers */
87 #define GET_DINFO(info)         (info)->par
88
89 /* misc macros */
90 #define ACCEL(d, i)                                                     \
91         ((d)->accel && !(d)->ring_lockup &&                             \
92          ((i)->var.accel_flags & FB_ACCELF_TEXT))
93
94 /*#define NOACCEL_CHIPSET(d)                                            \
95         ((d)->chipset != INTEL_865G)*/
96 #define NOACCEL_CHIPSET(d)                                              \
97         (0)
98
99 #define FIXED_MODE(d) ((d)->fixed_mode)
100
101 /*** Driver paramters ***/
102
103 #define RINGBUFFER_SIZE         KB(64)
104 #define HW_CURSOR_SIZE          KB(4)
105
106 /* Intel agpgart driver */
107 #define AGP_PHYSICAL_MEMORY     2
108
109 /*** Data Types ***/
110
111 /* supported chipsets */
112 enum intel_chips {
113         INTEL_830M,
114         INTEL_845G,
115         INTEL_85XGM,
116         INTEL_852GM,
117         INTEL_852GME,
118         INTEL_855GM,
119         INTEL_855GME,
120         INTEL_865G
121 };
122
123 struct intelfb_hwstate {
124         u32 vga0_divisor;
125         u32 vga1_divisor;
126         u32 vga_pd;
127         u32 dpll_a;
128         u32 dpll_b;
129         u32 fpa0;
130         u32 fpa1;
131         u32 fpb0;
132         u32 fpb1;
133         u32 palette_a[PALETTE_8_ENTRIES];
134         u32 palette_b[PALETTE_8_ENTRIES];
135         u32 htotal_a;
136         u32 hblank_a;
137         u32 hsync_a;
138         u32 vtotal_a;
139         u32 vblank_a;
140         u32 vsync_a;
141         u32 src_size_a;
142         u32 bclrpat_a;
143         u32 htotal_b;
144         u32 hblank_b;
145         u32 hsync_b;
146         u32 vtotal_b;
147         u32 vblank_b;
148         u32 vsync_b;
149         u32 src_size_b;
150         u32 bclrpat_b;
151         u32 adpa;
152         u32 dvoa;
153         u32 dvob;
154         u32 dvoc;
155         u32 dvoa_srcdim;
156         u32 dvob_srcdim;
157         u32 dvoc_srcdim;
158         u32 lvds;
159         u32 pipe_a_conf;
160         u32 pipe_b_conf;
161         u32 disp_arb;
162         u32 cursor_a_control;
163         u32 cursor_b_control;
164         u32 cursor_a_base;
165         u32 cursor_b_base;
166         u32 cursor_size;
167         u32 disp_a_ctrl;
168         u32 disp_b_ctrl;
169         u32 disp_a_base;
170         u32 disp_b_base;
171         u32 cursor_a_palette[4];
172         u32 cursor_b_palette[4];
173         u32 disp_a_stride;
174         u32 disp_b_stride;
175         u32 vgacntrl;
176         u32 add_id;
177         u32 swf0x[7];
178         u32 swf1x[7];
179         u32 swf3x[3];
180         u32 fence[8];
181         u32 instpm;
182         u32 mem_mode;
183         u32 fw_blc_0;
184         u32 fw_blc_1;
185 };
186
187 struct intelfb_heap_data {
188         u32 physical;
189         u8 __iomem *virtual;
190         u32 offset;  // in GATT pages
191         u32 size;    // in bytes
192 };
193
194 struct intelfb_info {
195         struct fb_info *info;
196         struct fb_ops  *fbops;
197         struct pci_dev *pdev;
198
199         struct intelfb_hwstate save_state;
200
201         /* agpgart structs */
202         struct agp_memory *gtt_fb_mem;     // use all stolen memory or vram
203         struct agp_memory *gtt_ring_mem;   // ring buffer
204         struct agp_memory *gtt_cursor_mem; // hw cursor
205
206         /* use a gart reserved fb mem */
207         u8 fbmem_gart;
208
209         /* mtrr support */
210         u32 mtrr_reg;
211         u32 has_mtrr;
212
213         /* heap data */
214         struct intelfb_heap_data aperture;
215         struct intelfb_heap_data fb;
216         struct intelfb_heap_data ring;
217         struct intelfb_heap_data cursor;
218
219         /* mmio regs */
220         u32 mmio_base_phys;
221         u8 __iomem *mmio_base;
222
223         /* fb start offset (in bytes) */
224         u32 fb_start;
225
226         /* ring buffer */
227         u8 __iomem *ring_head;
228         u32 ring_tail;
229         u32 ring_tail_mask;
230         u32 ring_space;
231         u32 ring_lockup;
232
233         /* palette */
234         u32 pseudo_palette[17];
235         struct { u8 red, green, blue, pad; } palette[256];
236
237         /* chip info */
238         int pci_chipset;
239         int chipset;
240         const char *name;
241         int mobile;
242
243         /* current mode */
244         int bpp, depth;
245         u32 visual;
246         int xres, yres, pitch;
247         int pixclock;
248
249         /* current pipe */
250         int pipe;
251
252         /* some flags */
253         int accel;
254         int hwcursor;
255         int fixed_mode;
256         int ring_active;
257
258         /* hw cursor */
259         int cursor_on;
260         int cursor_blanked;
261         u8  cursor_src[64];
262
263         /* initial parameters */
264         int initial_vga;
265         struct fb_var_screeninfo initial_var;
266         u32 initial_fb_base;
267         u32 initial_video_ram;
268         u32 initial_pitch;
269
270         /* driver registered */
271         int registered;
272 };
273
274 /*** function prototypes ***/
275
276 extern int intelfb_var_to_depth(const struct fb_var_screeninfo *var);
277
278 #endif /* _INTELFB_H */