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/i830.h,v 1.7 2003/01/28 22:47:09 dawes Exp $ */
34
* Keith Whitwell <keith@tungstengraphics.com>
35
* David Dawes <dawes@tungstengraphics.com>
43
#ifndef REMAP_RESERVED
44
#define REMAP_RESERVED 0
50
#include "xf86_ansic.h"
52
#include "xf86PciInfo.h"
56
#include "xf86Cursor.h"
58
#include "xf86int10.h"
65
#define _XF86DRI_SERVER_
68
#include "GL/glxint.h"
74
/* I830 Video BIOS support */
77
* The mode handling is based upon the VESA driver written by
78
* Paulo C�sar Pereira de Andrade <pcpa@conectiva.com.br>.
81
typedef struct _VESARec {
83
pointer state, pstate;
84
int statePage, stateSize, stateMode;
86
int savedScanlinePitch;
88
/* Don't try to set the refresh rate for any modes. */
89
Bool useDefaultRefresh;
93
typedef struct _I830Rec *I830Ptr;
95
typedef void (*I830WriteIndexedByteFunc)(I830Ptr pI830, IOADDRESS addr,
96
CARD8 index, CARD8 value);
97
typedef CARD8(*I830ReadIndexedByteFunc)(I830Ptr pI830, IOADDRESS addr,
99
typedef void (*I830WriteByteFunc)(I830Ptr pI830, IOADDRESS addr, CARD8 value);
100
typedef CARD8(*I830ReadByteFunc)(I830Ptr pI830, IOADDRESS addr);
102
/* Linear region allocated in framebuffer. */
103
typedef struct _I830MemPool *I830MemPoolPtr;
104
typedef struct _I830MemRange *I830MemRangePtr;
105
typedef struct _I830MemRange {
109
unsigned long Physical;
110
unsigned long Offset; /* Offset of AGP-allocated portion */
111
unsigned long Alignment;
116
typedef struct _I830MemPool {
120
I830MemRange Allocated;
126
unsigned char *virtual_start;
133
unsigned int Fence[8];
134
} I830RegRec, *I830RegPtr;
136
typedef struct _I830Rec {
137
unsigned char *MMIOBase;
138
unsigned char *FbBase;
141
unsigned int bufferOffset; /* for I830SelectBuffer */
145
/* These are set in PreInit and never changed. */
146
unsigned long FbMapSize;
147
unsigned long TotalVideoRam;
148
I830MemRange StolenMemory; /* pre-allocated memory */
149
unsigned long BIOSMemorySize; /* min stolen pool size */
151
/* These change according to what has been allocated. */
153
I830MemRange MemoryAperture;
154
I830MemPool StolenPool;
155
unsigned long allocatedMemory;
157
/* Regions allocated either from the above pools, or from agpgart. */
158
I830MemRange FrontBuffer;
159
I830MemRange CursorMem;
160
I830RingBuffer LpRing;
161
I830MemRange Scratch;
169
I830MemRange OverlayMem;
173
I830MemRange BackBuffer;
174
I830MemRange DepthBuffer;
176
I830MemRange BufferMem;
177
I830MemRange ContextMem;
183
Bool NeedRingBufferLow;
189
Bool CursorNeedsPhysical;
194
int DGAViewportStatus;
197
unsigned long LinearAddr;
198
unsigned long MMIOAddr;
209
unsigned char **ScanlineColorExpandBuffers;
210
int NumScanlineColorExpandBuffers;
211
int nextColorExpandBuf;
219
XAAInfoRecPtr AccelInfoRec;
220
xf86CursorInfoPtr CursorInfoRec;
221
CloseScreenProcPtr CloseScreen;
222
ScreenBlockHandlerProcPtr BlockHandler;
224
I830WriteIndexedByteFunc writeControl;
225
I830ReadIndexedByteFunc readControl;
226
I830WriteByteFunc writeStandard;
227
I830ReadByteFunc readStandard;
229
Bool XvDisabled; /* Xv disabled in PreInit. */
230
Bool XvEnabled; /* Xv enabled for this generation. */
234
XF86VideoAdaptorPtr adaptor;
238
Bool directRenderingDisabled; /* DRI disabled in PreInit. */
239
Bool directRenderingEnabled; /* DRI enabled this generation. */
242
Bool directRenderingOpen;
246
int numVisualConfigs;
247
__GLXvisualConfig *pVisualConfigs;
248
I830ConfigPrivPtr pVisualConfigsPriv;
249
drmHandle buffer_map;
253
OptionInfoPtr Options;
255
/* Stolen memory support */
258
/* Video BIOS support. */
260
VbeInfoBlock *vbeInfo;
263
Bool overrideBIOSMemSize;
273
/* Use BIOS call 0x5f64 to explicitly enable displays. */
275
/* Use BIOS call 0x5f05 to set the refresh rate. */
276
Bool useExtendedRefresh;
278
int configuredDevices;
280
/* These are indexed by the display types */
281
Bool displayAttached[NumDisplayTypes];
282
Bool displayPresent[NumDisplayTypes];
283
BoxRec displaySize[NumDisplayTypes];
285
/* [0] is Pipe A, [1] is Pipe B. */
287
int pipeDevices[MAX_DISPLAY_PIPES];
288
/* [0] is display plane A, [1] is display plane B. */
289
Bool pipeEnabled[MAX_DISPLAY_PIPES];
290
BoxRec pipeDisplaySize[MAX_DISPLAY_PIPES];
291
int planeEnabled[MAX_DISPLAY_PIPES];
293
/* Driver phase/state information */
300
#define I830PTR(p) ((I830Ptr)((p)->driverPrivate))
301
#define I830REGPTR(p) (&(I830PTR(p)->ModeReg))
303
#define I830_SELECT_FRONT 0
304
#define I830_SELECT_BACK 1
305
#define I830_SELECT_DEPTH 2
307
/* I830 specific functions */
308
extern int I830WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis);
309
extern void I830SetPIOAccess(I830Ptr pI830);
310
extern void I830SetMMIOAccess(I830Ptr pI830);
311
extern void I830PrintErrorState(ScrnInfoPtr pScrn);
312
extern void I830Sync(ScrnInfoPtr pScrn);
313
extern void I830InitHWCursor(ScrnInfoPtr pScrn);
314
extern Bool I830CursorInit(ScreenPtr pScreen);
315
extern void I830EmitInvarientState(ScrnInfoPtr pScrn);
316
extern void I830SelectBuffer(ScrnInfoPtr pScrn, int buffer);
318
extern void I830RefreshRing(ScrnInfoPtr pScrn);
319
extern void I830EmitFlush(ScrnInfoPtr pScrn);
321
extern Bool I830DGAInit(ScreenPtr pScreen);
324
extern void I830InitVideo(ScreenPtr pScreen);
325
extern void I830VideoSwitchModeBefore(ScrnInfoPtr pScrn, DisplayModePtr mode);
326
extern void I830VideoSwitchModeAfter(ScrnInfoPtr pScrn, DisplayModePtr mode);
330
extern Bool I830Allocate3DMemory(ScrnInfoPtr pScrn, const int flags);
331
extern void I830SetupMemoryTiling(ScrnInfoPtr pScrn);
332
extern Bool I830DRIScreenInit(ScreenPtr pScreen);
333
extern Bool I830DRIDoMappings(ScreenPtr pScreen);
334
extern void I830DRICloseScreen(ScreenPtr pScreen);
335
extern Bool I830DRIFinishScreenInit(ScreenPtr pScreen);
337
extern Bool I830AccelInit(ScreenPtr pScreen);
338
extern void I830SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
340
unsigned int planemask,
342
extern void I830SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX,
343
int srcY, int dstX, int dstY,
345
extern void I830SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
346
unsigned int planemask);
347
extern void I830SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y,
350
extern void I830ResetAllocations(ScrnInfoPtr pScrn, const int flags);
351
extern long I830CheckAvailableMemory(ScrnInfoPtr pScrn);
352
extern long I830GetExcessMemoryAllocations(ScrnInfoPtr pScrn);
353
extern Bool I830Allocate2DMemory(ScrnInfoPtr pScrn, const int flags);
354
extern Bool I830DoPoolAllocation(ScrnInfoPtr pScrn, I830MemPool *pool);
355
extern Bool I830FixupOffsets(ScrnInfoPtr pScrn);
356
extern Bool I830BindGARTMemory(ScrnInfoPtr pScrn);
357
extern Bool I830UnbindGARTMemory(ScrnInfoPtr pScrn);
358
extern unsigned long I830AllocVidMem(ScrnInfoPtr pScrn, I830MemRange *result,
359
I830MemPool *pool, unsigned long size,
360
unsigned long alignment, int flags);
362
extern void I830PrintAllRegisters(I830RegPtr i830Reg);
363
extern void I830ReadAllRegisters(I830Ptr pI830, I830RegPtr i830Reg);
365
extern void I830ChangeFrontbuffer(ScrnInfoPtr pScrn,int buffer);
368
* 12288 is set as the maximum, chosen because it is enough for
369
* 1920x1440@32bpp with a 2048 pixel line pitch with some to spare.
371
#define I830_MAXIMUM_VBIOS_MEM 12288
372
#define I830_DEFAULT_VIDEOMEM_2D (MB(8) / 1024)
373
#define I830_DEFAULT_VIDEOMEM_3D (MB(32) / 1024)
375
/* Flags for memory allocation function */
376
#define FROM_ANYWHERE 0x00000000
377
#define FROM_POOL_ONLY 0x00000001
378
#define FROM_NEW_ONLY 0x00000002
379
#define FROM_MASK 0x0000000f
381
#define ALLOCATE_AT_TOP 0x00000010
382
#define ALLOCATE_AT_BOTTOM 0x00000020
383
#define FORCE_GAPS 0x00000040
385
#define NEED_PHYSICAL_ADDR 0x00000100
386
#define ALIGN_BOTH_ENDS 0x00000200
387
#define FORCE_LOW 0x00000400
389
#define ALLOC_NO_TILING 0x00001000
390
#define ALLOC_INITIAL 0x00002000
392
#define ALLOCATE_DRY_RUN 0x80000000
395
#endif /* _I830_H_ */