blob: a50bea6148044bdf4fb08e1ce49c377fc2aa9939 [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 Munsie183b12142006-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 ***/
Phil Endecott3f7a26b2008-10-15 22:03:35 -070015#define INTELFB_VERSION "0.9.6"
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#define INTELFB_MODULE_NAME "intelfb"
Phil Endecott3f7a26b2008-10-15 22:03:35 -070017#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/945GME/965G/965GM"
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
Phil Endecott3f7a26b2008-10-15 22:03:35 -070061#define PCI_DEVICE_ID_INTEL_945GME 0x27AE
Maik Broemme0e170c72008-04-28 02:15:43 -070062#define PCI_DEVICE_ID_INTEL_965G 0x29A2
63#define PCI_DEVICE_ID_INTEL_965GM 0x2A02
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65/* Size of MMIO region */
66#define INTEL_REG_SIZE 0x80000
67
68#define STRIDE_ALIGNMENT 16
Dennis Munsiedf7df8a2006-05-27 18:17:52 +100069#define STRIDE_ALIGNMENT_I9XX 64
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71#define PALETTE_8_ENTRIES 256
72
73
74/*** Macros ***/
75
76/* basic arithmetic */
77#define KB(x) ((x) * 1024)
78#define MB(x) ((x) * 1024 * 1024)
79#define BtoKB(x) ((x) / 1024)
80#define BtoMB(x) ((x) / 1024 / 1024)
81
82#define GTT_PAGE_SIZE KB(4)
83
84#define ROUND_UP_TO(x, y) (((x) + (y) - 1) / (y) * (y))
85#define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
86#define ROUND_UP_TO_PAGE(x) ROUND_UP_TO((x), GTT_PAGE_SIZE)
87#define ROUND_DOWN_TO_PAGE(x) ROUND_DOWN_TO((x), GTT_PAGE_SIZE)
88
89/* messages */
90#define PFX INTELFB_MODULE_NAME ": "
91
92#define ERR_MSG(fmt, args...) printk(KERN_ERR PFX fmt, ## args)
93#define WRN_MSG(fmt, args...) printk(KERN_WARNING PFX fmt, ## args)
94#define NOT_MSG(fmt, args...) printk(KERN_NOTICE PFX fmt, ## args)
95#define INF_MSG(fmt, args...) printk(KERN_INFO PFX fmt, ## args)
96#if DEBUG
97#define DBG_MSG(fmt, args...) printk(KERN_DEBUG PFX fmt, ## args)
98#else
99#define DBG_MSG(fmt, args...) while (0) printk(fmt, ## args)
100#endif
101
102/* get commonly used pointers */
103#define GET_DINFO(info) (info)->par
104
105/* misc macros */
106#define ACCEL(d, i) \
107 ((d)->accel && !(d)->ring_lockup && \
108 ((i)->var.accel_flags & FB_ACCELF_TEXT))
109
110/*#define NOACCEL_CHIPSET(d) \
111 ((d)->chipset != INTEL_865G)*/
112#define NOACCEL_CHIPSET(d) \
113 (0)
114
115#define FIXED_MODE(d) ((d)->fixed_mode)
116
Joe Perches44363f12008-02-03 17:31:49 +0200117/*** Driver parameters ***/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119#define RINGBUFFER_SIZE KB(64)
120#define HW_CURSOR_SIZE KB(4)
121
122/* Intel agpgart driver */
123#define AGP_PHYSICAL_MEMORY 2
124
Dennis Munsiedd696ec2006-06-20 14:55:55 -0400125/* store information about an Ixxx DVO */
126/* The i830->i865 use multiple DVOs with multiple i2cs */
127/* the i915, i945 have a single sDVO i2c bus - which is different */
128#define MAX_OUTPUTS 6
129
Dennis Munsie399fb432006-06-20 14:55:55 -0400130/* these are outputs from the chip - integrated only
131 external chips are via DVO or SDVO output */
132#define INTELFB_OUTPUT_UNUSED 0
133#define INTELFB_OUTPUT_ANALOG 1
134#define INTELFB_OUTPUT_DVO 2
135#define INTELFB_OUTPUT_SDVO 3
136#define INTELFB_OUTPUT_LVDS 4
137#define INTELFB_OUTPUT_TVOUT 5
138
139#define INTELFB_DVO_CHIP_NONE 0
140#define INTELFB_DVO_CHIP_LVDS 1
141#define INTELFB_DVO_CHIP_TMDS 2
142#define INTELFB_DVO_CHIP_TVOUT 4
143
144#define INTELFB_OUTPUT_PIPE_NC 0
145#define INTELFB_OUTPUT_PIPE_A 1
146#define INTELFB_OUTPUT_PIPE_B 2
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148/*** Data Types ***/
149
150/* supported chipsets */
151enum intel_chips {
152 INTEL_830M,
153 INTEL_845G,
154 INTEL_85XGM,
155 INTEL_852GM,
156 INTEL_852GME,
157 INTEL_855GM,
158 INTEL_855GME,
159 INTEL_865G,
Scott MacKenzie3a590262005-11-07 01:00:33 -0800160 INTEL_915G,
Dave Airlie9639d5e2006-03-23 11:23:55 +1100161 INTEL_915GM,
Dave Airlie9a906032006-03-23 21:53:05 +1100162 INTEL_945G,
163 INTEL_945GM,
Phil Endecott3f7a26b2008-10-15 22:03:35 -0700164 INTEL_945GME,
Maik Broemme0e170c72008-04-28 02:15:43 -0700165 INTEL_965G,
166 INTEL_965GM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167};
168
169struct intelfb_hwstate {
170 u32 vga0_divisor;
171 u32 vga1_divisor;
172 u32 vga_pd;
173 u32 dpll_a;
174 u32 dpll_b;
175 u32 fpa0;
176 u32 fpa1;
177 u32 fpb0;
178 u32 fpb1;
179 u32 palette_a[PALETTE_8_ENTRIES];
180 u32 palette_b[PALETTE_8_ENTRIES];
181 u32 htotal_a;
182 u32 hblank_a;
183 u32 hsync_a;
184 u32 vtotal_a;
185 u32 vblank_a;
186 u32 vsync_a;
187 u32 src_size_a;
188 u32 bclrpat_a;
189 u32 htotal_b;
190 u32 hblank_b;
191 u32 hsync_b;
192 u32 vtotal_b;
193 u32 vblank_b;
194 u32 vsync_b;
195 u32 src_size_b;
196 u32 bclrpat_b;
197 u32 adpa;
198 u32 dvoa;
199 u32 dvob;
200 u32 dvoc;
201 u32 dvoa_srcdim;
202 u32 dvob_srcdim;
203 u32 dvoc_srcdim;
204 u32 lvds;
205 u32 pipe_a_conf;
206 u32 pipe_b_conf;
207 u32 disp_arb;
208 u32 cursor_a_control;
209 u32 cursor_b_control;
210 u32 cursor_a_base;
211 u32 cursor_b_base;
212 u32 cursor_size;
213 u32 disp_a_ctrl;
214 u32 disp_b_ctrl;
215 u32 disp_a_base;
216 u32 disp_b_base;
217 u32 cursor_a_palette[4];
218 u32 cursor_b_palette[4];
219 u32 disp_a_stride;
220 u32 disp_b_stride;
221 u32 vgacntrl;
222 u32 add_id;
223 u32 swf0x[7];
224 u32 swf1x[7];
225 u32 swf3x[3];
226 u32 fence[8];
227 u32 instpm;
228 u32 mem_mode;
229 u32 fw_blc_0;
230 u32 fw_blc_1;
Eric Hustvedt9a5f0192006-06-20 14:36:41 -0400231 u16 hwstam;
232 u16 ier;
233 u16 iir;
234 u16 imr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235};
236
237struct intelfb_heap_data {
238 u32 physical;
239 u8 __iomem *virtual;
Krzysztof Halasa689c9562007-10-16 01:29:31 -0700240 u32 offset; /* in GATT pages */
241 u32 size; /* in bytes */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242};
243
Dennis Munsie183b12142006-06-20 14:55:55 -0400244#ifdef CONFIG_FB_INTEL_I2C
245struct intelfb_i2c_chan {
246 struct intelfb_info *dinfo;
247 u32 reg;
248 struct i2c_adapter adapter;
249 struct i2c_algo_bit_data algo;
250};
251#endif
252
Dennis Munsie399fb432006-06-20 14:55:55 -0400253struct intelfb_output_rec {
254 int type;
255 int pipe;
256 int flags;
257
258#ifdef CONFIG_FB_INTEL_I2C
259 struct intelfb_i2c_chan i2c_bus;
260 struct intelfb_i2c_chan ddc_bus;
261#endif
262};
263
Eric Hustvedt76497572006-06-20 14:36:41 -0400264struct intelfb_vsync {
265 wait_queue_head_t wait;
266 unsigned int count;
Eric Hustvedtf80d0d22006-06-20 14:36:42 -0400267 int pan_display;
268 u32 pan_offset;
Eric Hustvedt76497572006-06-20 14:36:41 -0400269};
270
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271struct intelfb_info {
272 struct fb_info *info;
273 struct fb_ops *fbops;
274 struct pci_dev *pdev;
275
276 struct intelfb_hwstate save_state;
277
278 /* agpgart structs */
Krzysztof Halasa689c9562007-10-16 01:29:31 -0700279 struct agp_memory *gtt_fb_mem; /* use all stolen memory or vram */
280 struct agp_memory *gtt_ring_mem; /* ring buffer */
281 struct agp_memory *gtt_cursor_mem; /* hw cursor */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
283 /* use a gart reserved fb mem */
284 u8 fbmem_gart;
285
286 /* mtrr support */
Dave Airlied5afabc2006-08-22 10:10:56 +1000287 int mtrr_reg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 u32 has_mtrr;
289
290 /* heap data */
291 struct intelfb_heap_data aperture;
292 struct intelfb_heap_data fb;
293 struct intelfb_heap_data ring;
294 struct intelfb_heap_data cursor;
295
296 /* mmio regs */
297 u32 mmio_base_phys;
298 u8 __iomem *mmio_base;
299
300 /* fb start offset (in bytes) */
301 u32 fb_start;
302
303 /* ring buffer */
Al Viro0fe6e2d2006-06-23 06:05:39 +0100304 u32 ring_head;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 u32 ring_tail;
306 u32 ring_tail_mask;
307 u32 ring_space;
308 u32 ring_lockup;
309
310 /* palette */
Antonino A. Daplasc312f972007-07-17 04:05:44 -0700311 u32 pseudo_palette[16];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
313 /* chip info */
314 int pci_chipset;
315 int chipset;
316 const char *name;
317 int mobile;
318
319 /* current mode */
320 int bpp, depth;
321 u32 visual;
322 int xres, yres, pitch;
323 int pixclock;
324
325 /* current pipe */
326 int pipe;
327
328 /* some flags */
329 int accel;
330 int hwcursor;
331 int fixed_mode;
332 int ring_active;
Antonino A. Daplas4b3760c2005-12-19 15:11:40 +0800333 int flag;
Eric Hustvedt76497572006-06-20 14:36:41 -0400334 unsigned long irq_flags;
335 int open;
336
337 /* vsync */
338 struct intelfb_vsync vsync;
339 spinlock_t int_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
341 /* hw cursor */
342 int cursor_on;
343 int cursor_blanked;
344 u8 cursor_src[64];
345
346 /* initial parameters */
347 int initial_vga;
348 struct fb_var_screeninfo initial_var;
349 u32 initial_fb_base;
350 u32 initial_video_ram;
351 u32 initial_pitch;
352
353 /* driver registered */
354 int registered;
Krzysztof Halasa689c9562007-10-16 01:29:31 -0700355
Dave Airlied0249602006-03-20 20:26:45 +1100356 /* index into plls */
357 int pll_index;
Dennis Munsiedd696ec2006-06-20 14:55:55 -0400358
359 /* outputs */
360 int num_outputs;
361 struct intelfb_output_rec output[MAX_OUTPUTS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362};
363
Krzysztof Halasaee5618f2007-10-16 01:29:33 -0700364#define IS_I9XX(dinfo) (((dinfo)->chipset == INTEL_915G) || \
365 ((dinfo)->chipset == INTEL_915GM) || \
366 ((dinfo)->chipset == INTEL_945G) || \
Maik Broemme0e170c72008-04-28 02:15:43 -0700367 ((dinfo)->chipset == INTEL_945GM) || \
Phil Endecott3f7a26b2008-10-15 22:03:35 -0700368 ((dinfo)->chipset == INTEL_945GME) || \
Maik Broemme0e170c72008-04-28 02:15:43 -0700369 ((dinfo)->chipset == INTEL_965G) || \
370 ((dinfo)->chipset == INTEL_965GM))
Dave Airlie8bb91f62006-03-23 13:06:32 +1100371
Eric Hustvedt37bced32006-06-20 14:36:42 -0400372#ifndef FBIO_WAITFORVSYNC
373#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
374#endif
375
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376/*** function prototypes ***/
377
378extern int intelfb_var_to_depth(const struct fb_var_screeninfo *var);
379
Dennis Munsie41c94802006-06-20 14:55:55 -0400380#ifdef CONFIG_FB_INTEL_I2C
381extern void intelfb_create_i2c_busses(struct intelfb_info *dinfo);
Dennis Munsie76278992006-06-20 14:55:55 -0400382extern void intelfb_delete_i2c_busses(struct intelfb_info *dinfo);
Dennis Munsie41c94802006-06-20 14:55:55 -0400383#endif
384
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385#endif /* _INTELFB_H */