103b705cfSriastradh
203b705cfSriastradh/**************************************************************************
303b705cfSriastradh
403b705cfSriastradhCopyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
503b705cfSriastradhCopyright © 2002 David Dawes
603b705cfSriastradh
703b705cfSriastradhAll Rights Reserved.
803b705cfSriastradh
903b705cfSriastradhPermission is hereby granted, free of charge, to any person obtaining a
1003b705cfSriastradhcopy of this software and associated documentation files (the
1103b705cfSriastradh"Software"), to deal in the Software without restriction, including
1203b705cfSriastradhwithout limitation the rights to use, copy, modify, merge, publish,
1303b705cfSriastradhdistribute, sub license, and/or sell copies of the Software, and to
1403b705cfSriastradhpermit persons to whom the Software is furnished to do so, subject to
1503b705cfSriastradhthe following conditions:
1603b705cfSriastradh
1703b705cfSriastradhThe above copyright notice and this permission notice (including the
1803b705cfSriastradhnext paragraph) shall be included in all copies or substantial portions
1903b705cfSriastradhof the Software.
2003b705cfSriastradh
2103b705cfSriastradhTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2203b705cfSriastradhOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2303b705cfSriastradhMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
2403b705cfSriastradhIN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
2503b705cfSriastradhANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2603b705cfSriastradhTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2703b705cfSriastradhSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2803b705cfSriastradh
2903b705cfSriastradh**************************************************************************/
3003b705cfSriastradh
3103b705cfSriastradh/*
3203b705cfSriastradh * Authors:
3303b705cfSriastradh *   Keith Whitwell <keith@tungstengraphics.com>
3403b705cfSriastradh *   David Dawes <dawes@xfree86.org>
3503b705cfSriastradh *
3603b705cfSriastradh */
3703b705cfSriastradh
3803b705cfSriastradh#ifndef _I810_H_
3903b705cfSriastradh#define _I810_H_
4003b705cfSriastradh
4103b705cfSriastradh#include <stdint.h>
4203b705cfSriastradh#include "compiler.h"
4303b705cfSriastradh#include "xf86Pci.h"
4403b705cfSriastradh#include "i810_reg.h"
4503b705cfSriastradh#ifdef HAVE_XAA_H
4603b705cfSriastradh#include "xaa.h"
4703b705cfSriastradh#endif
4803b705cfSriastradh#include "xf86Cursor.h"
4903b705cfSriastradh#include "xf86xv.h"
5003b705cfSriastradh#include "vbe.h"
5103b705cfSriastradh#include "vgaHW.h"
5203b705cfSriastradh
5303b705cfSriastradh#include "xorg-server.h"
5403b705cfSriastradh#include <pciaccess.h>
5503b705cfSriastradh
5603b705cfSriastradh#include "compat-api.h"
5703b705cfSriastradh#ifdef HAVE_DRI1
5803b705cfSriastradh#include "xf86drm.h"
5903b705cfSriastradh#include "sarea.h"
6003b705cfSriastradh#define _XF86DRI_SERVER_
6103b705cfSriastradh#include "dri.h"
6203b705cfSriastradh#include "i810_dri.h"
6303b705cfSriastradh#endif
6403b705cfSriastradh
6503b705cfSriastradh#include "i810_common.h"
6603b705cfSriastradh#include "i810_ring.h"
6703b705cfSriastradh
6803b705cfSriastradh#include "intel_driver.h"
6903b705cfSriastradh
7003b705cfSriastradh/* HWMC Surfaces */
7103b705cfSriastradh#define I810_MAX_SURFACES 7
7203b705cfSriastradh#define I810_MAX_SUBPICTURES 2
7303b705cfSriastradh#define I810_TOTAL_SURFACES 9
7403b705cfSriastradh
7503b705cfSriastradh/* Globals */
7603b705cfSriastradh
7703b705cfSriastradhtypedef struct _I810Rec *I810Ptr;
7803b705cfSriastradh
7903b705cfSriastradhextern void I810SetTiledMemory(ScrnInfoPtr pScrn, int nr, unsigned start,
8003b705cfSriastradh			       unsigned pitch, unsigned size);
8103b705cfSriastradh
8203b705cfSriastradhtypedef struct {
8303b705cfSriastradh   unsigned long Start;
8403b705cfSriastradh   unsigned long End;
8503b705cfSriastradh   unsigned long Size;
8603b705cfSriastradh} I810MemRange;
8703b705cfSriastradh
8803b705cfSriastradhtypedef struct {
8903b705cfSriastradh   int tail_mask;
9003b705cfSriastradh   I810MemRange mem;
9103b705cfSriastradh   unsigned char *virtual_start;
9203b705cfSriastradh   int head;
9303b705cfSriastradh   int tail;
9403b705cfSriastradh   int space;
9503b705cfSriastradh} I810RingBuffer;
9603b705cfSriastradh
9703b705cfSriastradhtypedef struct {
9803b705cfSriastradh   unsigned char DisplayControl;
9903b705cfSriastradh   unsigned char PixelPipeCfg0;
10003b705cfSriastradh   unsigned char PixelPipeCfg1;
10103b705cfSriastradh   unsigned char PixelPipeCfg2;
10203b705cfSriastradh   unsigned short VideoClk2_M;
10303b705cfSriastradh   unsigned short VideoClk2_N;
10403b705cfSriastradh   unsigned char VideoClk2_DivisorSel;
10503b705cfSriastradh   unsigned char AddressMapping;
10603b705cfSriastradh   unsigned char IOControl;
10703b705cfSriastradh   unsigned char BitBLTControl;
10803b705cfSriastradh   unsigned char ExtVertTotal;
10903b705cfSriastradh   unsigned char ExtVertDispEnd;
11003b705cfSriastradh   unsigned char ExtVertSyncStart;
11103b705cfSriastradh   unsigned char ExtVertBlankStart;
11203b705cfSriastradh   unsigned char ExtHorizTotal;
11303b705cfSriastradh   unsigned char ExtHorizBlank;
11403b705cfSriastradh   unsigned char ExtOffset;
11503b705cfSriastradh   unsigned char InterlaceControl;
11603b705cfSriastradh   unsigned int LMI_FIFO_Watermark;
11703b705cfSriastradh
11803b705cfSriastradh   unsigned int LprbTail;
11903b705cfSriastradh   unsigned int LprbHead;
12003b705cfSriastradh   unsigned int LprbStart;
12103b705cfSriastradh   unsigned int LprbLen;
12203b705cfSriastradh
12303b705cfSriastradh   unsigned int Fence[8];
12403b705cfSriastradh
12503b705cfSriastradh   unsigned short OverlayActiveStart;
12603b705cfSriastradh   unsigned short OverlayActiveEnd;
12703b705cfSriastradh
12803b705cfSriastradh} I810RegRec, *I810RegPtr;
12903b705cfSriastradh
13003b705cfSriastradhtypedef struct _I810Rec {
13103b705cfSriastradh   unsigned char *MMIOBase;
13203b705cfSriastradh   unsigned char *FbBase;
13303b705cfSriastradh   long FbMapSize;
13403b705cfSriastradh   long DepthOffset;
13503b705cfSriastradh   long BackOffset;
13603b705cfSriastradh   int cpp;
13703b705cfSriastradh   int MaxClock;
13803b705cfSriastradh
13903b705cfSriastradh   unsigned int bufferOffset;		/* for I810SelectBuffer */
14003b705cfSriastradh   Bool DoneFrontAlloc;
14103b705cfSriastradh   BoxRec FbMemBox;
14203b705cfSriastradh   I810MemRange FrontBuffer;
14303b705cfSriastradh   I810MemRange BackBuffer;
14403b705cfSriastradh   I810MemRange DepthBuffer;
14503b705cfSriastradh   I810MemRange TexMem;
14603b705cfSriastradh   I810MemRange Scratch;
14703b705cfSriastradh   I810MemRange BufferMem;
14803b705cfSriastradh   I810MemRange ContextMem;
14903b705cfSriastradh   I810MemRange MC;
15003b705cfSriastradh
15103b705cfSriastradh   int auxPitch;
15203b705cfSriastradh   int auxPitchBits;
15303b705cfSriastradh
15403b705cfSriastradh   Bool CursorIsARGB;
15503b705cfSriastradh   int CursorOffset;
15603b705cfSriastradh   unsigned long CursorPhysical;
15703b705cfSriastradh   unsigned long CursorStart;
15803b705cfSriastradh   int CursorARGBOffset;
15903b705cfSriastradh   unsigned long CursorARGBPhysical;
16003b705cfSriastradh   unsigned long CursorARGBStart;
16103b705cfSriastradh   unsigned long OverlayPhysical;
16203b705cfSriastradh   unsigned long OverlayStart;
16303b705cfSriastradh   int colorKey;
16403b705cfSriastradh   unsigned int surfaceAllocation[I810_TOTAL_SURFACES];
16503b705cfSriastradh   int numSurfaces;
16603b705cfSriastradh
16703b705cfSriastradh   DGAModePtr DGAModes;
16803b705cfSriastradh   int numDGAModes;
16903b705cfSriastradh   Bool DGAactive;
17003b705cfSriastradh   int DGAViewportStatus;
17103b705cfSriastradh
17203b705cfSriastradh   int Chipset;
17303b705cfSriastradh   unsigned long LinearAddr;
17403b705cfSriastradh   unsigned long MMIOAddr;
17503b705cfSriastradh   EntityInfoPtr pEnt;
17603b705cfSriastradh   struct pci_device *PciInfo;
17703b705cfSriastradh
17803b705cfSriastradh   I810RingBuffer *LpRing;
17903b705cfSriastradh   unsigned int BR[20];
18003b705cfSriastradh
18103b705cfSriastradh   int LmFreqSel;
18203b705cfSriastradh
18303b705cfSriastradh   int VramKey;
18403b705cfSriastradh   unsigned long VramOffset;
18503b705cfSriastradh   int DcacheKey;
18603b705cfSriastradh   unsigned long DcacheOffset;
18703b705cfSriastradh   int HwcursKey;
18803b705cfSriastradh   unsigned long HwcursOffset;
18903b705cfSriastradh   int ARGBHwcursKey;
19003b705cfSriastradh   unsigned long ARGBHwcursOffset;
19103b705cfSriastradh
19203b705cfSriastradh   int GttBound;
19303b705cfSriastradh
19403b705cfSriastradh   I810MemRange DcacheMem;
19503b705cfSriastradh   I810MemRange SysMem;
19603b705cfSriastradh
19703b705cfSriastradh   I810MemRange SavedDcacheMem;
19803b705cfSriastradh   I810MemRange SavedSysMem;
19903b705cfSriastradh
20003b705cfSriastradh   unsigned char **ScanlineColorExpandBuffers;
20103b705cfSriastradh   int NumScanlineColorExpandBuffers;
20203b705cfSriastradh   int nextColorExpandBuf;
20303b705cfSriastradh
20403b705cfSriastradh   I810RegRec SavedReg;
20503b705cfSriastradh   I810RegRec ModeReg;
20603b705cfSriastradh
20703b705cfSriastradh#ifdef HAVE_XAA_H
20803b705cfSriastradh   XAAInfoRecPtr AccelInfoRec;
20903b705cfSriastradh#endif
21003b705cfSriastradh   xf86CursorInfoPtr CursorInfoRec;
21103b705cfSriastradh   CloseScreenProcPtr CloseScreen;
21203b705cfSriastradh   ScreenBlockHandlerProcPtr BlockHandler;
21303b705cfSriastradh
21403b705cfSriastradh   Bool directRenderingDisabled;        /* DRI disabled in PreInit */
21503b705cfSriastradh   Bool directRenderingEnabled;		/* false if XF86DRI not defined. */
21603b705cfSriastradh
21703b705cfSriastradh#ifdef HAVE_DRI1
21803b705cfSriastradh   int LockHeld;
21903b705cfSriastradh   DRIInfoPtr pDRIInfo;
22003b705cfSriastradh   int drmSubFD;
22103b705cfSriastradh   unsigned long dcacheHandle;
22203b705cfSriastradh   unsigned long backHandle;
22303b705cfSriastradh   unsigned long zHandle;
22403b705cfSriastradh   unsigned long cursorHandle;
22503b705cfSriastradh   unsigned long cursorARGBHandle;
22603b705cfSriastradh   unsigned long xvmcHandle;
22703b705cfSriastradh   unsigned long sysmemHandle;
22803b705cfSriastradh   Bool agpAcquired;
22903b705cfSriastradh   drm_handle_t buffer_map;
23003b705cfSriastradh   drm_handle_t ring_map;
23103b705cfSriastradh   drm_handle_t overlay_map;
23203b705cfSriastradh   drm_handle_t mc_map;
23303b705cfSriastradh   drm_handle_t xvmcContext;
23403b705cfSriastradh#endif
23503b705cfSriastradh   Bool agpAcquired2d;
23603b705cfSriastradh
23703b705cfSriastradh   XF86VideoAdaptorPtr adaptor;
23803b705cfSriastradh   OptionInfoPtr Options;
23903b705cfSriastradh
24003b705cfSriastradh   int configured_device;
24103b705cfSriastradh
24203b705cfSriastradh   Bool showCache;
24303b705cfSriastradh   Bool noAccel;
24403b705cfSriastradh   Bool allowPageFlip;
24503b705cfSriastradh   Bool have3DWindows;
24603b705cfSriastradh   int  drmMinor;
24703b705cfSriastradh} I810Rec;
24803b705cfSriastradh
24903b705cfSriastradh#define I810PTR(p) ((I810Ptr)((p)->driverPrivate))
25003b705cfSriastradh
25103b705cfSriastradh#define I810_SELECT_FRONT	0
25203b705cfSriastradh#define I810_SELECT_BACK	1
25303b705cfSriastradh#define I810_SELECT_DEPTH	2
25403b705cfSriastradh
25503b705cfSriastradh#ifdef HAVE_DRI1
25603b705cfSriastradhextern Bool I810DRIScreenInit(ScreenPtr pScreen);
25703b705cfSriastradhextern void I810DRICloseScreen(ScreenPtr pScreen);
25803b705cfSriastradhextern Bool I810DRIFinishScreenInit(ScreenPtr pScreen);
25903b705cfSriastradhextern Bool I810DRILeave(ScrnInfoPtr pScrn);
26003b705cfSriastradhextern Bool I810DRIEnter(ScrnInfoPtr pScrn);
26103b705cfSriastradh#endif
26203b705cfSriastradhextern Bool I810InitDma(ScrnInfoPtr pScrn);
26303b705cfSriastradhextern Bool I810CleanupDma(ScrnInfoPtr pScrn);
26403b705cfSriastradh
26503b705cfSriastradh#define I810PTR(p) ((I810Ptr)((p)->driverPrivate))
26603b705cfSriastradh#define I810REGPTR(p) (&(I810PTR(p)->ModeReg))
26703b705cfSriastradh
26803b705cfSriastradhextern Bool I810CursorInit(ScreenPtr pScreen);
26903b705cfSriastradh#ifdef HAVE_XAA_H
27003b705cfSriastradhextern Bool I810AccelInit(ScreenPtr pScreen);
27103b705cfSriastradh#else
27203b705cfSriastradhstatic inline  Bool I810AccelInit(ScreenPtr pScreen) { return TRUE; }
27303b705cfSriastradh#endif
27403b705cfSriastradhextern void I810SetPIOAccess(I810Ptr pI810);
27503b705cfSriastradhextern void I810SetMMIOAccess(I810Ptr pI810);
27603b705cfSriastradhextern unsigned int I810CalcWatermark(ScrnInfoPtr pScrn, double freq,
27703b705cfSriastradh				      Bool dcache);
27803b705cfSriastradhextern void I810PrintErrorState(ScrnInfoPtr pScrn);
27903b705cfSriastradhextern int I810WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis);
28003b705cfSriastradhextern void I810Sync(ScrnInfoPtr pScrn);
28103b705cfSriastradhextern unsigned long I810LocalToPhysical(ScrnInfoPtr pScrn,
28203b705cfSriastradh					 unsigned long local);
28303b705cfSriastradhextern int I810AllocLow(I810MemRange * result, I810MemRange * pool,
28403b705cfSriastradh			int size);
28503b705cfSriastradhextern int I810AllocHigh(I810MemRange * result, I810MemRange * pool,
28603b705cfSriastradh			int size);
28703b705cfSriastradhextern Bool I810AllocateFront(ScrnInfoPtr pScrn);
28803b705cfSriastradh
28903b705cfSriastradhextern int I810AllocateGARTMemory(ScrnInfoPtr pScrn);
29003b705cfSriastradhextern void I810FreeGARTMemory(ScrnInfoPtr pScrn);
29103b705cfSriastradh
29203b705cfSriastradhextern Bool I810BindGARTMemory(ScrnInfoPtr pScrn);
29303b705cfSriastradhextern Bool I810UnbindGARTMemory(ScrnInfoPtr pScrn);
29403b705cfSriastradh
29503b705cfSriastradhextern int I810CheckAvailableMemory(ScrnInfoPtr pScrn);
29603b705cfSriastradh
29703b705cfSriastradhextern Bool I810SwitchMode(SWITCH_MODE_ARGS_DECL);
29803b705cfSriastradhextern void I810AdjustFrame(ADJUST_FRAME_ARGS_DECL);
29903b705cfSriastradh
30003b705cfSriastradhextern void I810SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
30103b705cfSriastradh					   int ydir, int rop,
30203b705cfSriastradh					   unsigned int planemask,
30303b705cfSriastradh					   int trans_color);
30403b705cfSriastradhextern void I810SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX,
30503b705cfSriastradh					     int srcY, int dstX, int dstY,
30603b705cfSriastradh					     int w, int h);
30703b705cfSriastradhextern void I810SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
30803b705cfSriastradh				  unsigned int planemask);
30903b705cfSriastradhextern void I810SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y,
31003b705cfSriastradh					int w, int h);
31103b705cfSriastradh
31203b705cfSriastradhextern void I810SelectBuffer(ScrnInfoPtr pScrn, int buffer);
31303b705cfSriastradh
31403b705cfSriastradhextern void I810RefreshRing(ScrnInfoPtr pScrn);
31503b705cfSriastradhextern void I810EmitFlush(ScrnInfoPtr pScrn);
31603b705cfSriastradh
31703b705cfSriastradhextern Bool I810DGAInit(ScreenPtr pScreen);
31803b705cfSriastradh
31903b705cfSriastradhextern void I810InitVideo(ScreenPtr pScreen);
32003b705cfSriastradhextern void I810InitMC(ScreenPtr pScreen);
32103b705cfSriastradh
32203b705cfSriastradhextern const OptionInfoRec *I810AvailableOptions(int chipid, int busid);
32303b705cfSriastradh
32403b705cfSriastradhextern const int I810CopyROP[16];
325ad01e365Sjoergextern const int I810PatternROP[16];
32603b705cfSriastradh
32703b705cfSriastradh#endif /* _I810_H_ */
328