4
#include "xf86drm.h" /* drm_handle_t, etc */
8
#define PCI_CHIP_I810 0x7121
9
#define PCI_CHIP_I810_DC100 0x7123
10
#define PCI_CHIP_I810_E 0x7125
11
#define PCI_CHIP_I815 0x1132
12
#define PCI_CHIP_I810_BRIDGE 0x7120
13
#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
14
#define PCI_CHIP_I810_E_BRIDGE 0x7124
15
#define PCI_CHIP_I815_BRIDGE 0x1130
18
#define PCI_CHIP_845_G 0x2562
19
#define PCI_CHIP_I830_M 0x3577
21
#ifndef PCI_CHIP_I855_GM
22
#define PCI_CHIP_I855_GM 0x3582
23
#define PCI_CHIP_I855_GM_BRIDGE 0x3580
26
#ifndef PCI_CHIP_I865_G
27
#define PCI_CHIP_I865_G 0x2572
28
#define PCI_CHIP_I865_G_BRIDGE 0x2570
31
#ifndef PCI_CHIP_I915_G
32
#define PCI_CHIP_I915_G 0x2582
33
#define PCI_CHIP_I915_G_BRIDGE 0x2580
36
#ifndef PCI_CHIP_I915_GM
37
#define PCI_CHIP_I915_GM 0x2592
38
#define PCI_CHIP_I915_GM_BRIDGE 0x2590
41
#ifndef PCI_CHIP_E7221_G
42
#define PCI_CHIP_E7221_G 0x258A
43
/* Same as I915_G_BRIDGE */
44
#define PCI_CHIP_E7221_G_BRIDGE 0x2580
47
#ifndef PCI_CHIP_I945_G
48
#define PCI_CHIP_I945_G 0x2772
49
#define PCI_CHIP_I945_G_BRIDGE 0x2770
52
#ifndef PCI_CHIP_I945_GM
53
#define PCI_CHIP_I945_GM 0x27A2
54
#define PCI_CHIP_I945_GM_BRIDGE 0x27A0
57
#define IS_I810(pI810) (pI810->Chipset == PCI_CHIP_I810 || \
58
pI810->Chipset == PCI_CHIP_I810_DC100 || \
59
pI810->Chipset == PCI_CHIP_I810_E)
60
#define IS_I815(pI810) (pI810->Chipset == PCI_CHIP_I815)
61
#define IS_I830(pI810) (pI810->Chipset == PCI_CHIP_I830_M)
62
#define IS_845G(pI810) (pI810->Chipset == PCI_CHIP_845_G)
63
#define IS_I85X(pI810) (pI810->Chipset == PCI_CHIP_I855_GM)
64
#define IS_I852(pI810) (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I852_GM || pI810->variant == I852_GME))
65
#define IS_I855(pI810) (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I855_GM || pI810->variant == I855_GME))
66
#define IS_I865G(pI810) (pI810->Chipset == PCI_CHIP_I865_G)
68
#define IS_I915G(pI810) (pI810->Chipset == PCI_CHIP_I915_G || pI810->Chipset == PCI_CHIP_E7221_G)
69
#define IS_I915GM(pI810) (pI810->Chipset == PCI_CHIP_I915_GM)
70
#define IS_I945G(pI810) (pI810->Chipset == PCI_CHIP_I945_G)
71
#define IS_I945GM(pI810) (pI810->Chipset == PCI_CHIP_I945_GM)
72
#define IS_I9XX(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810))
74
#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810))
76
#define I830_GMCH_CTRL 0x52
78
#define I830_GMCH_MEM_MASK 0x1
79
#define I830_GMCH_MEM_64M 0x1
80
#define I830_GMCH_MEM_128M 0
82
#define I830_GMCH_GMS_MASK 0x70
83
#define I830_GMCH_GMS_DISABLED 0x00
84
#define I830_GMCH_GMS_LOCAL 0x10
85
#define I830_GMCH_GMS_STOLEN_512 0x20
86
#define I830_GMCH_GMS_STOLEN_1024 0x30
87
#define I830_GMCH_GMS_STOLEN_8192 0x40
89
#define I855_GMCH_GMS_MASK (0x7 << 4)
90
#define I855_GMCH_GMS_DISABLED 0x00
91
#define I855_GMCH_GMS_STOLEN_1M (0x1 << 4)
92
#define I855_GMCH_GMS_STOLEN_4M (0x2 << 4)
93
#define I855_GMCH_GMS_STOLEN_8M (0x3 << 4)
94
#define I855_GMCH_GMS_STOLEN_16M (0x4 << 4)
95
#define I855_GMCH_GMS_STOLEN_32M (0x5 << 4)
96
#define I915G_GMCH_GMS_STOLEN_48M (0x6 << 4)
97
#define I915G_GMCH_GMS_STOLEN_64M (0x7 << 4)
99
typedef unsigned char Bool;
103
#define PIPE_NONE 0<<0
104
#define PIPE_CRT 1<<0
106
#define PIPE_DFP 1<<2
107
#define PIPE_LFP 1<<3
108
#define PIPE_CRT2 1<<4
109
#define PIPE_TV2 1<<5
110
#define PIPE_DFP2 1<<6
111
#define PIPE_LFP2 1<<7
113
typedef struct _I830MemPool *I830MemPoolPtr;
114
typedef struct _I830MemRange *I830MemRangePtr;
115
typedef struct _I830MemRange {
119
unsigned long Physical;
120
unsigned long Offset; /* Offset of AGP-allocated portion */
121
unsigned long Alignment;
123
unsigned long Pitch; // add pitch
127
typedef struct _I830MemPool {
131
I830MemRange Allocated;
137
unsigned char *virtual_start;
143
typedef struct _I830Rec {
144
unsigned char *MMIOBase;
145
unsigned char *FbBase;
148
unsigned int bios_version;
150
/* These are set in PreInit and never changed. */
153
I830MemRange StolenMemory; /* pre-allocated memory */
154
long BIOSMemorySize; /* min stolen pool size */
157
/* These change according to what has been allocated. */
159
I830MemRange MemoryAperture;
160
I830MemPool StolenPool;
161
long allocatedMemory;
163
/* Regions allocated either from the above pools, or from agpgart. */
164
/* for single and dual head configurations */
165
I830MemRange FrontBuffer;
166
I830MemRange FrontBuffer2;
167
I830MemRange Scratch;
168
I830MemRange Scratch2;
170
I830RingBuffer *LpRing;
172
I830MemRange BackBuffer;
173
I830MemRange DepthBuffer;
176
I830MemRange ContextMem;
180
Bool NeedRingBufferLow;
185
unsigned long LinearAddr;
186
unsigned long MMIOAddr;
188
drmSize registerSize; /**< \brief MMIO register map size */
189
drm_handle_t registerHandle; /**< \brief MMIO register map handle */
191
int irq; /**< \brief IRQ number */
194
drm_handle_t ring_map;
195
unsigned int Fence[8];
200
* 12288 is set as the maximum, chosen because it is enough for
201
* 1920x1440@32bpp with a 2048 pixel line pitch with some to spare.
203
#define I830_MAXIMUM_VBIOS_MEM 12288
204
#define I830_DEFAULT_VIDEOMEM_2D (MB(32) / 1024)
205
#define I830_DEFAULT_VIDEOMEM_3D (MB(64) / 1024)
207
/* Flags for memory allocation function */
208
#define FROM_ANYWHERE 0x00000000
209
#define FROM_POOL_ONLY 0x00000001
210
#define FROM_NEW_ONLY 0x00000002
211
#define FROM_MASK 0x0000000f
213
#define ALLOCATE_AT_TOP 0x00000010
214
#define ALLOCATE_AT_BOTTOM 0x00000020
215
#define FORCE_GAPS 0x00000040
217
#define NEED_PHYSICAL_ADDR 0x00000100
218
#define ALIGN_BOTH_ENDS 0x00000200
219
#define FORCE_LOW 0x00000400
221
#define ALLOC_NO_TILING 0x00001000
222
#define ALLOC_INITIAL 0x00002000
224
#define ALLOCATE_DRY_RUN 0x80000000
226
/* Chipset registers for VIDEO BIOS memory RW access */
227
#define _855_DRAM_RW_CONTROL 0x58
228
#define _845_DRAM_RW_CONTROL 0x90
229
#define DRAM_WRITE 0x33330000
231
#define KB(x) ((x) * 1024)
232
#define MB(x) ((x) * KB(1024))
234
#define GTT_PAGE_SIZE KB(4)
235
#define ROUND_TO(x, y) (((x) + (y) - 1) / (y) * (y))
236
#define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
237
#define ROUND_TO_PAGE(x) ROUND_TO((x), GTT_PAGE_SIZE)
238
#define ROUND_TO_MB(x) ROUND_TO((x), MB(1))
239
#define PRIMARY_RINGBUFFER_SIZE KB(128)
242
/* Ring buffer registers, p277, overview p19
244
#define LP_RING 0x2030
245
#define HP_RING 0x2040
247
#define RING_TAIL 0x00
248
#define TAIL_ADDR 0x000FFFF8
249
#define I830_TAIL_MASK 0x001FFFF8
251
#define RING_HEAD 0x04
252
#define HEAD_WRAP_COUNT 0xFFE00000
253
#define HEAD_WRAP_ONE 0x00200000
254
#define HEAD_ADDR 0x001FFFFC
255
#define I830_HEAD_MASK 0x001FFFFC
257
#define RING_START 0x08
258
#define START_ADDR 0x03FFFFF8
259
#define I830_RING_START_MASK 0xFFFFF000
261
#define RING_LEN 0x0C
262
#define RING_NR_PAGES 0x001FF000
263
#define I830_RING_NR_PAGES 0x001FF000
264
#define RING_REPORT_MASK 0x00000006
265
#define RING_REPORT_64K 0x00000002
266
#define RING_REPORT_128K 0x00000004
267
#define RING_NO_REPORT 0x00000000
268
#define RING_VALID_MASK 0x00000001
269
#define RING_VALID 0x00000001
270
#define RING_INVALID 0x00000000
273
/* Fence/Tiling ranges [0..7]
278
#define I915G_FENCE_START_MASK 0x0ff00000
280
#define I830_FENCE_START_MASK 0x07f80000
282
#define FENCE_START_MASK 0x03F80000
283
#define FENCE_X_MAJOR 0x00000000
284
#define FENCE_Y_MAJOR 0x00001000
285
#define FENCE_SIZE_MASK 0x00000700
286
#define FENCE_SIZE_512K 0x00000000
287
#define FENCE_SIZE_1M 0x00000100
288
#define FENCE_SIZE_2M 0x00000200
289
#define FENCE_SIZE_4M 0x00000300
290
#define FENCE_SIZE_8M 0x00000400
291
#define FENCE_SIZE_16M 0x00000500
292
#define FENCE_SIZE_32M 0x00000600
293
#define FENCE_SIZE_64M 0x00000700
294
#define I915G_FENCE_SIZE_1M 0x00000000
295
#define I915G_FENCE_SIZE_2M 0x00000100
296
#define I915G_FENCE_SIZE_4M 0x00000200
297
#define I915G_FENCE_SIZE_8M 0x00000300
298
#define I915G_FENCE_SIZE_16M 0x00000400
299
#define I915G_FENCE_SIZE_32M 0x00000500
300
#define I915G_FENCE_SIZE_64M 0x00000600
301
#define I915G_FENCE_SIZE_128M 0x00000700
302
#define FENCE_PITCH_1 0x00000000
303
#define FENCE_PITCH_2 0x00000010
304
#define FENCE_PITCH_4 0x00000020
305
#define FENCE_PITCH_8 0x00000030
306
#define FENCE_PITCH_16 0x00000040
307
#define FENCE_PITCH_32 0x00000050
308
#define FENCE_PITCH_64 0x00000060
309
#define FENCE_VALID 0x00000001
313
# define MMIO_IN8(base, offset) \
314
*(volatile unsigned char *)(((unsigned char*)(base)) + (offset))
315
# define MMIO_IN32(base, offset) \
316
read_MMIO_LE32(base, offset)
317
# define MMIO_OUT8(base, offset, val) \
318
*(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val)
319
# define MMIO_OUT32(base, offset, val) \
320
*(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = CPU_TO_LE32(val)
323
/* Memory mapped register access macros */
324
#define INREG8(addr) MMIO_IN8(MMIO, addr)
325
#define INREG(addr) MMIO_IN32(MMIO, addr)
326
#define OUTREG8(addr, val) MMIO_OUT8(MMIO, addr, val)
327
#define OUTREG(addr, val) MMIO_OUT32(MMIO, addr, val)
329
#define DSPABASE 0x70184