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