2
/**************************************************************************
4
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
5
Copyright � 2002 David Dawes
9
Permission is hereby granted, free of charge, to any person obtaining a
10
copy of this software and associated documentation files (the
11
"Software"), to deal in the Software without restriction, including
12
without limitation the rights to use, copy, modify, merge, publish,
13
distribute, sub license, and/or sell copies of the Software, and to
14
permit persons to whom the Software is furnished to do so, subject to
15
the following conditions:
17
The above copyright notice and this permission notice (including the
18
next paragraph) shall be included in all copies or substantial portions
21
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
24
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
25
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
**************************************************************************/
30
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/common.h,v 1.6 2003/02/06 04:18:04 dawes Exp $ */
34
* Keith Whitwell <keith@tungstengraphics.com>
35
* David Dawes <dawes@tungstengraphics.com>
39
#ifndef _INTEL_COMMON_H_
40
#define _INTEL_COMMON_H_
43
#define PFX __FILE__,__LINE__,__FUNCTION__
44
#define FUNCTION_NAME __FUNCTION__
46
#define PFX __FILE__,__LINE__,""
47
#define FUNCTION_NAME ""
51
#define MARKER() ErrorF("\n### %s:%d: >>> %s <<< ###\n\n", \
52
__FILE__, __LINE__,__FUNCTION__)
53
#define DPRINTF I830DPRINTF_stub
54
#else /* #ifdef I830DEBUG */
56
/* this is a real ugly hack to get the compiler to optimize the debugging statements into oblivion */
57
#define DPRINTF if(0) I830DPRINTF_stub
58
#endif /* #ifdef I830DEBUG */
60
#define KB(x) ((x) * 1024)
61
#define MB(x) ((x) * KB(1024))
63
/* Using usleep() makes things noticably slow. */
65
#define DELAY(x) usleep(x)
67
#define DELAY(x) do {;} while (0)
70
/* I830 hooks for the I810 driver setup/probe. */
71
extern const OptionInfoRec *I830BIOSAvailableOptions(int chipid, int busid);
72
extern void I830InitpScrn(ScrnInfoPtr pScrn);
74
/* Symbol lists shared by the i810 and i830 parts. */
75
extern const char *I810vgahwSymbols[];
76
extern const char *I810ramdacSymbols[];
77
extern const char *I810int10Symbols[];
78
extern const char *I810vbeSymbols[];
79
extern const char *I810ddcSymbols[];
80
extern const char *I810fbSymbols[];
81
extern const char *I810xaaSymbols[];
82
extern const char *I810shadowSymbols[];
84
extern void I830DPRINTF_stub(const char *filename, int line,
85
const char *function, const char *fmt, ...);
88
#define PrintErrorState I830PrintErrorState
89
#define WaitRingFunc I830WaitLpRing
92
#define PrintErrorState I810PrintErrorState
93
#define WaitRingFunc I810WaitLpRing
97
/* BIOS debug macro */
98
#define xf86ExecX86int10_wrapper(pInt, pScrn) do { \
99
if (I810_DEBUG & DEBUG_VERBOSE_BIOS) { \
100
ErrorF("\n\n\n\nExecuting (ax == 0x%x) BIOS call\n", pInt->ax); \
101
ErrorF("Checking Error state before execution\n"); \
102
PrintErrorState(pScrn); \
104
xf86ExecX86int10(pInt); \
105
if(I810_DEBUG & DEBUG_VERBOSE_BIOS) { \
106
ErrorF("Checking Error state after execution\n"); \
108
PrintErrorState(pScrn); \
112
#define OUT_RING(n) do { \
113
if (I810_DEBUG & DEBUG_VERBOSE_RING) \
114
ErrorF( "OUT_RING %x: %x, (mask %x)\n", outring, n, ringmask); \
115
*(volatile unsigned int *)(virt + outring) = n; \
117
outring &= ringmask; \
121
#define ADVANCE_LP_RING() do { \
122
RecPtr->LpRing.tail = outring; \
123
if (outring & 0x07) \
124
ErrorF("ADVANCE_LP_RING: " \
125
"outring (0x%x) isn't on a QWord boundary", outring); \
126
OUTREG(LP_RING + RING_TAIL, outring); \
129
#define ADVANCE_LP_RING() { \
130
RecPtr->LpRing.tail = outring; \
131
if (outring & 0x07) \
132
ErrorF("ADVANCE_LP_RING: " \
133
"outring (0x%x) isn't on a QWord boundary", outring); \
134
ErrorF("head is %d, tail is %d [%d]\n", INREG(LP_RING + RING_HEAD), INREG(LP_RING + RING_TAIL), outring); \
135
OUTREG(LP_RING + RING_TAIL, outring); \
136
ErrorF("head is %d, tail is %d [%d]\n", INREG(LP_RING + RING_HEAD), INREG(LP_RING + RING_TAIL), outring); \
141
* XXX Note: the head/tail masks are different for 810 and i830.
142
* If the i810 always sets the higher bits to 0, then this shouldn't be
143
* a problem. Check this!
145
#define DO_RING_IDLE() do { \
149
_head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK; \
150
_tail = INREG(LP_RING + RING_TAIL) & I830_TAIL_MASK; \
152
} while (_head != _tail); \
156
* This is for debugging a potential problem writing the tail pointer
157
* close to the end of the ring buffer.
159
#ifndef AVOID_TAIL_END
160
#define AVOID_TAIL_END 0
163
#define AVOID_SIZE 64
168
#define BEGIN_LP_RING(n) \
169
unsigned int outring, ringmask; \
170
volatile unsigned char *virt; \
171
unsigned int needed; \
173
ErrorF("BEGIN_LP_RING called with odd argument: %d\n", n); \
174
if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC)) \
177
if ((RecPtr->LpRing.tail > RecPtr->LpRing.tail_mask - AVOID_SIZE) || \
178
(RecPtr->LpRing.tail + needed) > \
179
RecPtr->LpRing.tail_mask - AVOID_SIZE) { \
180
needed += RecPtr->LpRing.tail_mask + 1 - RecPtr->LpRing.tail; \
181
ErrorF("BEGIN_LP_RING: skipping last 64 bytes of " \
182
"ring (%d vs %d)\n", needed, (n) * 4); \
184
if (RecPtr->LpRing.space < needed) \
185
WaitRingFunc(pScrn, needed, 0); \
186
RecPtr->LpRing.space -= needed; \
187
outring = RecPtr->LpRing.tail; \
188
ringmask = RecPtr->LpRing.tail_mask; \
189
virt = RecPtr->LpRing.virtual_start; \
190
while (needed > (n) * 4) { \
191
ErrorF("BEGIN_LP_RING: putting MI_NOOP at 0x%x (remaining %d)\n", \
192
outring, needed - (n) * 4); \
196
if (I810_DEBUG & DEBUG_VERBOSE_RING) \
197
ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);
199
#else /* AVOID_TAIL_END */
201
#define BEGIN_LP_RING(n) \
202
unsigned int outring, ringmask; \
203
volatile unsigned char *virt; \
204
unsigned int needed; \
206
ErrorF("BEGIN_LP_RING called with odd argument: %d\n", n); \
207
if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC)) \
210
if (RecPtr->LpRing.space < needed) \
211
WaitRingFunc(pScrn, needed, 0); \
212
RecPtr->LpRing.space -= needed; \
213
outring = RecPtr->LpRing.tail; \
214
ringmask = RecPtr->LpRing.tail_mask; \
215
virt = RecPtr->LpRing.virtual_start; \
216
if (I810_DEBUG & DEBUG_VERBOSE_RING) \
217
ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);
219
#endif /* AVOID_TAIL_END */
222
/* Memory mapped register access macros */
223
#define INREG8(addr) *(volatile CARD8 *)(RecPtr->MMIOBase + (addr))
224
#define INREG16(addr) *(volatile CARD16 *)(RecPtr->MMIOBase + (addr))
225
#define INREG(addr) *(volatile CARD32 *)(RecPtr->MMIOBase + (addr))
227
#define OUTREG8(addr, val) do { \
228
*(volatile CARD8 *)(RecPtr->MMIOBase + (addr)) = (val); \
229
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
230
ErrorF("OUTREG8(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME); \
234
#define OUTREG16(addr, val) do { \
235
*(volatile CARD16 *)(RecPtr->MMIOBase + (addr)) = (val); \
236
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
237
ErrorF("OUTREG16(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME); \
241
#define OUTREG(addr, val) do { \
242
*(volatile CARD32 *)(RecPtr->MMIOBase + (addr)) = (val); \
243
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) { \
244
ErrorF("OUTREG(0x%x, 0x%x) in %s\n", addr, val, FUNCTION_NAME); \
248
/* To remove all debugging, make sure I810_DEBUG is defined as a
249
* preprocessor symbol, and equal to zero.
255
#warning "Debugging enabled - expect reduced performance"
256
extern int I810_DEBUG;
259
#define DEBUG_VERBOSE_ACCEL 0x1
260
#define DEBUG_VERBOSE_SYNC 0x2
261
#define DEBUG_VERBOSE_VGA 0x4
262
#define DEBUG_VERBOSE_RING 0x8
263
#define DEBUG_VERBOSE_OUTREG 0x10
264
#define DEBUG_VERBOSE_MEMORY 0x20
265
#define DEBUG_VERBOSE_CURSOR 0x40
266
#define DEBUG_ALWAYS_SYNC 0x80
267
#define DEBUG_VERBOSE_DRI 0x100
268
#define DEBUG_VERBOSE_BIOS 0x200
270
/* Size of the mmio region.
272
#define I810_REG_SIZE 0x80000
274
#ifndef PCI_CHIP_I810
275
#define PCI_CHIP_I810 0x7121
276
#define PCI_CHIP_I810_DC100 0x7123
277
#define PCI_CHIP_I810_E 0x7125
278
#define PCI_CHIP_I815 0x1132
279
#define PCI_CHIP_I810_BRIDGE 0x7120
280
#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
281
#define PCI_CHIP_I810_E_BRIDGE 0x7124
282
#define PCI_CHIP_I815_BRIDGE 0x1130
285
#ifndef PCI_CHIP_I855_GM
286
#define PCI_CHIP_I855_GM 0x3582
287
#define PCI_CHIP_I855_GM_BRIDGE 0x3580
290
#ifndef PCI_CHIP_I865_G
291
#define PCI_CHIP_I865_G 0x2572
292
#define PCI_CHIP_I865_G_BRIDGE 0x2570
295
#define IS_I810(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I810 || \
296
pI810->PciInfo->chipType == PCI_CHIP_I810_DC100 || \
297
pI810->PciInfo->chipType == PCI_CHIP_I810_E)
298
#define IS_I815(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I815)
299
#define IS_I830(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I830_M)
300
#define IS_845G(pI810) (pI810->PciInfo->chipType == PCI_CHIP_845_G)
301
#define IS_I85X(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I855_GM)
302
#define IS_I865G(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I865_G)
304
#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810))
306
#define GTT_PAGE_SIZE KB(4)
307
#define ROUND_TO(x, y) (((x) + (y) - 1) / (y) * (y))
308
#define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
309
#define ROUND_TO_PAGE(x) ROUND_TO((x), GTT_PAGE_SIZE)
310
#define ROUND_TO_MB(x) ROUND_TO((x), MB(1))
311
#define PRIMARY_RINGBUFFER_SIZE KB(128)
312
#define MIN_SCRATCH_BUFFER_SIZE KB(16)
313
#define MAX_SCRATCH_BUFFER_SIZE KB(64)
314
#define HWCURSOR_SIZE GTT_PAGE_SIZE
315
#define OVERLAY_SIZE GTT_PAGE_SIZE
317
/* Use a 64x64 HW cursor */
318
#define I810_CURSOR_X 64
319
#define I810_CURSOR_Y I810_CURSOR_X
321
/* XXX Need to check if these are reasonable. */
322
#define MAX_DISPLAY_PITCH 2048
323
#define MAX_DISPLAY_HEIGHT 2048
325
#define PIPE_NAME(n) ('A' + (n))
327
#endif /* _INTEL_COMMON_H_ */