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