blob: 5a216b81aa23b24595482ff17795f770b51ec8a4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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
Dennis Munsie183b1212006-06-20 14:55:55 -04009#ifdef CONFIG_FB_INTEL_I2C
10#include <linux/i2c.h>
11#include <linux/i2c-algo-bit.h>
12#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14/*** Version/name ***/
Dave Airlie9a906032006-03-23 21:53:05 +110015#define INTELFB_VERSION "0.9.4"
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#define INTELFB_MODULE_NAME "intelfb"
Dave Airlie9a906032006-03-23 21:53:05 +110017#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM"
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19
20/*** Debug/feature defines ***/
21
22#ifndef DEBUG
23#define DEBUG 0
24#endif
25
26#ifndef VERBOSE
27#define VERBOSE 0
28#endif
29
30#ifndef REGDUMP
31#define REGDUMP 0
32#endif
33
34#ifndef DETECT_VGA_CLASS_ONLY
35#define DETECT_VGA_CLASS_ONLY 1
36#endif
37
38#ifndef ALLOCATE_FOR_PANNING
39#define ALLOCATE_FOR_PANNING 1
40#endif
41
42#ifndef PREFERRED_MODE
43#define PREFERRED_MODE "1024x768-32@70"
44#endif
45
46/*** hw-related values ***/
47
Antonino A. Daplas4b3760c2005-12-19 15:11:40 +080048/* Resource Allocation */
49#define INTELFB_FB_ACQUIRED 1
50#define INTELFB_MMIO_ACQUIRED 2
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052/* PCI ids for supported devices */
53#define PCI_DEVICE_ID_INTEL_830M 0x3577
54#define PCI_DEVICE_ID_INTEL_845G 0x2562
55#define PCI_DEVICE_ID_INTEL_85XGM 0x3582
56#define PCI_DEVICE_ID_INTEL_865G 0x2572
57#define PCI_DEVICE_ID_INTEL_915G 0x2582
Scott MacKenzie3a590262005-11-07 01:00:33 -080058#define PCI_DEVICE_ID_INTEL_915GM 0x2592
Dave Airlie9639d5e2006-03-23 11:23:55 +110059#define PCI_DEVICE_ID_INTEL_945G 0x2772
Dave Airlie9a906032006-03-23 21:53:05 +110060#define PCI_DEVICE_ID_INTEL_945GM 0x27A2
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62/* Size of MMIO region */
63#define INTEL_REG_SIZE 0x80000
64
65#define STRIDE_ALIGNMENT 16
Dennis Munsiedf7df8a2006-05-27 18:17:52 +100066#define STRIDE_ALIGNMENT_I9XX 64
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68#define PALETTE_8_ENTRIES 256
69
70
71/*** Macros ***/
72
73/* basic arithmetic */
74#define KB(x) ((x) * 1024)
75#define MB(x) ((x) * 1024 * 1024)
76#define BtoKB(x) ((x) / 1024)
77#define BtoMB(x) ((x) / 1024 / 1024)
78
79#define GTT_PAGE_SIZE KB(4)
80
81#define ROUND_UP_TO(x, y) (((x) + (y) - 1) / (y) * (y))
82#define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
83#define ROUND_UP_TO_PAGE(x) ROUND_UP_TO((x), GTT_PAGE_SIZE)
84#define ROUND_DOWN_TO_PAGE(x) ROUND_DOWN_TO((x), GTT_PAGE_SIZE)
85
86/* messages */
87#define PFX INTELFB_MODULE_NAME ": "
88
89#define ERR_MSG(fmt, args...) printk(KERN_ERR PFX fmt, ## args)
90#define WRN_MSG(fmt, args...) printk(KERN_WARNING PFX fmt, ## args)
91#define NOT_MSG(fmt, args...) printk(KERN_NOTICE PFX fmt, ## args)
92#define INF_MSG(fmt, args...) printk(KERN_INFO PFX fmt, ## args)
93#if DEBUG
94#define DBG_MSG(fmt, args...) printk(KERN_DEBUG PFX fmt, ## args)
95#else
96#define DBG_MSG(fmt, args...) while (0) printk(fmt, ## args)
97#endif
98
99/* get commonly used pointers */
100#define GET_DINFO(info) (info)->par
101
102/* misc macros */
103#define ACCEL(d, i) \
104 ((d)->accel && !(d)->ring_lockup && \
105 ((i)->var.accel_flags & FB_ACCELF_TEXT))
106
107/*#define NOACCEL_CHIPSET(d) \
108 ((d)->chipset != INTEL_865G)*/
109#define NOACCEL_CHIPSET(d) \
110 (0)
111
112#define FIXED_MODE(d) ((d)->fixed_mode)
113
114/*** Driver paramters ***/
115
116#define RINGBUFFER_SIZE KB(64)
117#define HW_CURSOR_SIZE KB(4)
118
119/* Intel agpgart driver */
120#define AGP_PHYSICAL_MEMORY 2
121
122/*** Data Types ***/
123
124/* supported chipsets */
125enum intel_chips {
126 INTEL_830M,
127 INTEL_845G,
128 INTEL_85XGM,
129 INTEL_852GM,
130 INTEL_852GME,
131 INTEL_855GM,
132 INTEL_855GME,
133 INTEL_865G,
Scott MacKenzie3a590262005-11-07 01:00:33 -0800134 INTEL_915G,
Dave Airlie9639d5e2006-03-23 11:23:55 +1100135 INTEL_915GM,
Dave Airlie9a906032006-03-23 21:53:05 +1100136 INTEL_945G,
137 INTEL_945GM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138};
139
140struct intelfb_hwstate {
141 u32 vga0_divisor;
142 u32 vga1_divisor;
143 u32 vga_pd;
144 u32 dpll_a;
145 u32 dpll_b;
146 u32 fpa0;
147 u32 fpa1;
148 u32 fpb0;
149 u32 fpb1;
150 u32 palette_a[PALETTE_8_ENTRIES];
151 u32 palette_b[PALETTE_8_ENTRIES];
152 u32 htotal_a;
153 u32 hblank_a;
154 u32 hsync_a;
155 u32 vtotal_a;
156 u32 vblank_a;
157 u32 vsync_a;
158 u32 src_size_a;
159 u32 bclrpat_a;
160 u32 htotal_b;
161 u32 hblank_b;
162 u32 hsync_b;
163 u32 vtotal_b;
164 u32 vblank_b;
165 u32 vsync_b;
166 u32 src_size_b;
167 u32 bclrpat_b;
168 u32 adpa;
169 u32 dvoa;
170 u32 dvob;
171 u32 dvoc;
172 u32 dvoa_srcdim;
173 u32 dvob_srcdim;
174 u32 dvoc_srcdim;
175 u32 lvds;
176 u32 pipe_a_conf;
177 u32 pipe_b_conf;
178 u32 disp_arb;
179 u32 cursor_a_control;
180 u32 cursor_b_control;
181 u32 cursor_a_base;
182 u32 cursor_b_base;
183 u32 cursor_size;
184 u32 disp_a_ctrl;
185 u32 disp_b_ctrl;
186 u32 disp_a_base;
187 u32 disp_b_base;
188 u32 cursor_a_palette[4];
189 u32 cursor_b_palette[4];
190 u32 disp_a_stride;
191 u32 disp_b_stride;
192 u32 vgacntrl;
193 u32 add_id;
194 u32 swf0x[7];
195 u32 swf1x[7];
196 u32 swf3x[3];
197 u32 fence[8];
198 u32 instpm;
199 u32 mem_mode;
200 u32 fw_blc_0;
201 u32 fw_blc_1;
Eric Hustvedt9a5f0192006-06-20 14:36:41 -0400202 u16 hwstam;
203 u16 ier;
204 u16 iir;
205 u16 imr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206};
207
208struct intelfb_heap_data {
209 u32 physical;
210 u8 __iomem *virtual;
211 u32 offset; // in GATT pages
212 u32 size; // in bytes
213};
214
Dennis Munsie183b1212006-06-20 14:55:55 -0400215#ifdef CONFIG_FB_INTEL_I2C
216struct intelfb_i2c_chan {
217 struct intelfb_info *dinfo;
218 u32 reg;
219 struct i2c_adapter adapter;
220 struct i2c_algo_bit_data algo;
221};
222#endif
223
Eric Hustvedt76497572006-06-20 14:36:41 -0400224struct intelfb_vsync {
225 wait_queue_head_t wait;
226 unsigned int count;
Eric Hustvedtf80d0d22006-06-20 14:36:42 -0400227 int pan_display;
228 u32 pan_offset;
Eric Hustvedt76497572006-06-20 14:36:41 -0400229};
230
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231struct intelfb_info {
232 struct fb_info *info;
233 struct fb_ops *fbops;
234 struct pci_dev *pdev;
235
236 struct intelfb_hwstate save_state;
237
238 /* agpgart structs */
239 struct agp_memory *gtt_fb_mem; // use all stolen memory or vram
240 struct agp_memory *gtt_ring_mem; // ring buffer
241 struct agp_memory *gtt_cursor_mem; // hw cursor
242
243 /* use a gart reserved fb mem */
244 u8 fbmem_gart;
245
246 /* mtrr support */
247 u32 mtrr_reg;
248 u32 has_mtrr;
249
250 /* heap data */
251 struct intelfb_heap_data aperture;
252 struct intelfb_heap_data fb;
253 struct intelfb_heap_data ring;
254 struct intelfb_heap_data cursor;
255
256 /* mmio regs */
257 u32 mmio_base_phys;
258 u8 __iomem *mmio_base;
259
260 /* fb start offset (in bytes) */
261 u32 fb_start;
262
263 /* ring buffer */
Al Viro0fe6e2d2006-06-23 06:05:39 +0100264 u32 ring_head;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265 u32 ring_tail;
266 u32 ring_tail_mask;
267 u32 ring_space;
268 u32 ring_lockup;
269
270 /* palette */
271 u32 pseudo_palette[17];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
273 /* chip info */
274 int pci_chipset;
275 int chipset;
276 const char *name;
277 int mobile;
278
279 /* current mode */
280 int bpp, depth;
281 u32 visual;
282 int xres, yres, pitch;
283 int pixclock;
284
285 /* current pipe */
286 int pipe;
287
288 /* some flags */
289 int accel;
290 int hwcursor;
291 int fixed_mode;
292 int ring_active;
Antonino A. Daplas4b3760c2005-12-19 15:11:40 +0800293 int flag;
Eric Hustvedt76497572006-06-20 14:36:41 -0400294 unsigned long irq_flags;
295 int open;
296
297 /* vsync */
298 struct intelfb_vsync vsync;
299 spinlock_t int_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301 /* hw cursor */
302 int cursor_on;
303 int cursor_blanked;
304 u8 cursor_src[64];
305
306 /* initial parameters */
307 int initial_vga;
308 struct fb_var_screeninfo initial_var;
309 u32 initial_fb_base;
310 u32 initial_video_ram;
311 u32 initial_pitch;
312
313 /* driver registered */
314 int registered;
Dave Airlied0249602006-03-20 20:26:45 +1100315
316 /* index into plls */
317 int pll_index;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318};
319
Dave Airlie3aff13c2006-03-31 17:08:52 +1000320#define IS_I9XX(dinfo) (((dinfo)->chipset == INTEL_915G)||(dinfo->chipset == INTEL_915GM)||((dinfo)->chipset == INTEL_945G)||(dinfo->chipset==INTEL_945GM))
Dave Airlie8bb91f62006-03-23 13:06:32 +1100321
Eric Hustvedt37bced32006-06-20 14:36:42 -0400322#ifndef FBIO_WAITFORVSYNC
323#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
324#endif
325
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326/*** function prototypes ***/
327
328extern int intelfb_var_to_depth(const struct fb_var_screeninfo *var);
329
330#endif /* _INTELFB_H */