1 /*
2  * Copyright (C) 1994-2000 The XFree86 Project, Inc.  All Rights Reserved.
3  * Copyright (c) 2003-2006, X.Org Foundation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18  * COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Except as contained in this notice, the name of the copyright holder(s)
24  * and author(s) shall not be used in advertising or otherwise to promote
25  * the sale, use or other dealings in this Software without prior written
26  * authorization from the copyright holder(s) and author(s).
27  */
28 
29 #ifndef SAVAGE_DRIVER_H
30 #define SAVAGE_DRIVER_H
31 
32 #include <stdio.h>
33 #include <string.h>
34 #include <math.h>
35 
36 #ifdef XSERVER_LIBPCIACCESS
37 #include <pciaccess.h>
38 #define VENDOR_ID(p)      (p)->vendor_id
39 #define DEVICE_ID(p)      (p)->device_id
40 #define SUBSYS_ID(p)      (p)->subdevice_id
41 #define CHIP_REVISION(p)  (p)->revision
42 #else
43 #define VENDOR_ID(p)      (p)->vendor
44 #define DEVICE_ID(p)      (p)->chipType
45 #define SUBSYS_ID(p)      (p)->subsysCard
46 #define CHIP_REVISION(p)  (p)->chipRev
47 #endif
48 
49 #define MODE_24 24
50 
51 #include "compiler.h"
52 #include "vgaHW.h"
53 #include "xf86.h"
54 #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6
55 #include "xf86Resources.h"
56 #endif
57 #include "xf86Modes.h"
58 #include "xf86Pci.h"
59 #include "xf86_OSproc.h"
60 #include "xf86Cursor.h"
61 #include "mipointer.h"
62 #include "micmap.h"
63 #include "fb.h"
64 #include "fboverlay.h"
65 #include "xf86cmap.h"
66 #include "vbe.h"
67 #ifdef HAVE_XAA_H
68 #include "xaa.h"
69 #endif
70 #include "xf86fbman.h"
71 #include "exa.h"
72 #include "xf86xv.h"
73 
74 #include "savage_regs.h"
75 #include "savage_vbe.h"
76 
77 #ifndef XF86DRI
78 #undef SAVAGEDRI
79 #endif
80 
81 #ifdef SAVAGEDRI
82 #define _XF86DRI_SERVER_
83 #include "savage_dripriv.h"
84 #include "savage_dri.h"
85 #include "dri.h"
86 #include "GL/glxint.h"
87 #include "xf86drm.h"
88 
89 /* Totals 2 Mbytes which equals 2^16 32-byte vertices divided among up
90  * to 32 clients. */
91 #define SAVAGE_NUM_BUFFERS 32
92 #define SAVAGE_BUFFER_SIZE (1 << 16) /* 64k */
93 
94 #define SAVAGE_CMDDMA_SIZE 0x100000 /* 1MB */
95 
96 #define SAVAGE_DEFAULT_AGP_MODE     1
97 #define SAVAGE_MAX_AGP_MODE         4
98 
99 /* Buffer are aligned on 4096 byte boundaries.
100  */
101 /*  this is used for backbuffer, depthbuffer, etc..*/
102 /*          alignment                                      */
103 
104 #define SAVAGE_BUFFER_ALIGN	0x00000fff
105 
106 typedef struct _server{
107    int reserved_map_agpstart;
108    int reserved_map_idx;
109 
110    int sarea_priv_offset;
111 
112    int chipset;
113    int sgram;     /* seems no use */
114 
115    unsigned int frontOffset;
116    unsigned int frontPitch;
117    unsigned int frontbufferSize;
118    unsigned int frontBitmapDesc;
119 
120    unsigned int backOffset;
121    unsigned int backPitch;
122    unsigned int backbufferSize;
123    unsigned int backBitmapDesc;
124 
125    unsigned int depthOffset;
126    unsigned int depthPitch;
127    unsigned int depthbufferSize;
128    unsigned int depthBitmapDesc;
129 
130    unsigned int textureOffset;
131    int textureSize;
132    int logTextureGranularity;
133 
134    drmRegion agp;
135 
136    /* PCI mappings */
137    drmRegion aperture;
138    drmRegion registers;
139    drmRegion status;
140 
141    /* AGP mappings */
142    drmRegion buffers;
143    drmRegion agpTextures;
144    int logAgpTextureGranularity;
145 
146    /* command DMA */
147    drmRegion cmdDma;
148 
149    /* XVideo through AGP */
150    drmRegion agpXVideo;
151 } SAVAGEDRIServerPrivateRec, *SAVAGEDRIServerPrivatePtr;
152 
153 #endif
154 
155 #include "compat-api.h"
156 
157 typedef enum {
158     MT_NONE,
159     MT_CRT,
160     MT_LCD,
161     MT_DFP,
162     MT_TV
163 } SavageMonitorType;
164 
165 typedef struct
166 {
167     Bool HasSecondary;
168     Bool TvOn;
169     ScrnInfoPtr pSecondaryScrn;
170     ScrnInfoPtr pPrimaryScrn;
171 
172 } SavageEntRec, *SavageEntPtr;
173 
174 #define VGAIN8(addr) MMIO_IN8(psav->MapBase+0x8000, addr)
175 #define VGAIN16(addr) MMIO_IN16(psav->MapBase+0x8000, addr)
176 #define VGAIN(addr) MMIO_IN32(psav->MapBase+0x8000, addr)
177 
178 #define VGAOUT8(addr,val) MMIO_OUT8(psav->MapBase+0x8000, addr, val)
179 #define VGAOUT16(addr,val) MMIO_OUT16(psav->MapBase+0x8000, addr, val)
180 #define VGAOUT(addr,val) MMIO_OUT32(psav->MapBase+0x8000, addr, val)
181 
182 #define INREG8(addr) MMIO_IN8(psav->MapBase, addr)
183 #define INREG16(addr) MMIO_IN16(psav->MapBase, addr)
184 #define INREG32(addr) MMIO_IN32(psav->MapBase, addr)
185 #define OUTREG8(addr,val) MMIO_OUT8(psav->MapBase, addr, val)
186 #define OUTREG16(addr,val) MMIO_OUT16(psav->MapBase, addr, val)
187 #define OUTREG32(addr,val) MMIO_OUT32(psav->MapBase, addr, val)
188 #define INREG(addr) INREG32(addr)
189 #define OUTREG(addr,val) OUTREG32(addr,val)
190 
191 #if X_BYTE_ORDER == X_LITTLE_ENDIAN
192 #define B_O16(x)  (x)
193 #define B_O32(x)  (x)
194 #else
195 #define B_O16(x)  ((((x) & 0xff) << 8) | (((x) & 0xff) >> 8))
196 #define B_O32(x)  ((((x) & 0xff) << 24) | (((x) & 0xff00) << 8) \
197                   | (((x) & 0xff0000) >> 8) | (((x) & 0xff000000) >> 24))
198 #endif
199 #define L_ADD(x)  (B_O32(x) & 0xffff) + ((B_O32(x) >> 12) & 0xffff00)
200 
201 #define SAVAGEIOMAPSIZE	0x80000
202 
203 #define SAVAGE_CRT_ON	1
204 #define SAVAGE_LCD_ON	2
205 #define SAVAGE_TV_ON	4
206 
207 #define SAVAGE_DRIVER_NAME	"savage"
208 #define SAVAGE_DRIVER_VERSION	PACKAGE_VERSION
209 #define SAVAGE_VERSION_MAJOR	PACKAGE_VERSION_MAJOR
210 #define SAVAGE_VERSION_MINOR	PACKAGE_VERSION_MINOR
211 #define SAVAGE_PATCHLEVEL	PACKAGE_VERSION_PATCHLEVEL
212 #define SAVAGE_VERSION	((SAVAGE_VERSION_MAJOR << 24) | \
213 			 (SAVAGE_VERSION_MINOR << 16) | \
214 			 SAVAGE_PATCHLEVEL)
215 
216 typedef struct _S3VMODEENTRY {
217    unsigned short Width;
218    unsigned short Height;
219    unsigned short VesaMode;
220    unsigned char RefreshCount;
221    unsigned char * RefreshRate;
222 } SavageModeEntry, *SavageModeEntryPtr;
223 
224 
225 typedef struct _S3VMODETABLE {
226    unsigned short NumModes;
227    SavageModeEntry Modes[1];
228 } SavageModeTableRec, *SavageModeTablePtr;
229 
230 
231 typedef struct {
232     unsigned int mode, refresh;
233     unsigned char SR08, SR0E, SR0F;
234     unsigned char SR10, SR11, SR12, SR13, SR15, SR18, SR1B, SR29, SR30;
235     unsigned char SR54[8];
236     unsigned char Clock;
237     unsigned char CR31, CR32, CR33, CR34, CR36, CR3A, CR3B, CR3C;
238     unsigned char CR40, CR41, CR42, CR43, CR45;
239     unsigned char CR50, CR51, CR53, CR55, CR58, CR5B, CR5D, CR5E;
240     unsigned char CR60, CR63, CR65, CR66, CR67, CR68, CR69, CR6D, CR6F;
241     unsigned char CR86, CR88;
242     unsigned char CR90, CR91, CRB0;
243     unsigned int  STREAMS[22];	/* yuck, streams regs */
244     unsigned int  MMPR0, MMPR1, MMPR2, MMPR3;
245 } SavageRegRec, *SavageRegPtr;
246 
247 typedef  struct {
248     CARD32 redMask, greenMask, blueMask;
249     int redShift, greenShift, blueShift;
250 } savageOverlayRec;
251 
252 /*  Tiling defines */
253 #define TILE_SIZE_BYTE          2048   /* 0x800, 2K */
254 #define TILE_SIZE_BYTE_2000     4096
255 
256 #define TILEHEIGHT_16BPP        16
257 #define TILEHEIGHT_32BPP        16
258 #define TILEHEIGHT              16      /* all 16 and 32bpp tiles are 16 lines high */
259 #define TILEHEIGHT_2000         32      /* 32 lines on savage 2000 */
260 
261 #define TILEWIDTH_BYTES         128     /* 2048/TILEHEIGHT (** not for use w/8bpp tiling) */
262 #define TILEWIDTH8BPP_BYTES     64      /* 2048/TILEHEIGHT_8BPP */
263 #define TILEWIDTH_16BPP         64      /* TILEWIDTH_BYTES/2-BYTES-PER-PIXEL */
264 #define TILEWIDTH_32BPP         32      /* TILEWIDTH_BYTES/4-BYTES-PER-PIXEL */
265 
266 /* Bitmap descriptor structures for BCI */
267 typedef struct _HIGH {
268     unsigned short Stride;
269     unsigned char Bpp;
270     unsigned char ResBWTile;
271 } HIGH;
272 
273 typedef struct _BMPDESC1 {
274     unsigned long Offset;
275     HIGH  HighPart;
276 } BMPDESC1;
277 
278 typedef struct _BMPDESC2 {
279     unsigned long LoPart;
280     unsigned long HiPart;
281 } BMPDESC2;
282 
283 typedef union _BMPDESC {
284     BMPDESC1 bd1;
285     BMPDESC2 bd2;
286 } BMPDESC;
287 
288 typedef struct _StatInfo {
289     int     origMode;
290     int     pageCnt;
291     pointer statBuf;
292     int     realSeg;
293     int     realOff;
294 } StatInfoRec,*StatInfoPtr;
295 
296 struct savage_region {
297 #ifdef XSERVER_LIBPCIACCESS
298     pciaddr_t       base;
299     pciaddr_t       size;
300 #else
301     unsigned long   base;
302     unsigned long   size;
303 #endif
304     void          * memory;
305 };
306 
307 typedef struct _Savage {
308     SavageRegRec	SavedReg;
309     SavageRegRec	ModeReg;
310     xf86CursorInfoPtr	CursorInfoRec;
311     Bool		ModeStructInit;
312     Bool		NeedSTREAMS;
313     Bool		STREAMSRunning;
314     int			Bpp, Bpl, ScissB;
315     unsigned		PlaneMask;
316     I2CBusPtr		I2C;
317     I2CBusPtr		DVI;
318     unsigned char       DDCPort;
319     unsigned char       I2CPort;
320 
321     int			videoRambytes;
322     int			videoRamKbytes;
323     int			MemOffScreen;
324     int			CursorKByte;
325     int			endfb;
326 
327     /* These are physical addresses. */
328     unsigned long	ShadowPhysical;
329 
330     /* These are linear addresses. */
331     struct savage_region   MmioRegion;
332     struct savage_region   FbRegion;
333     struct savage_region   ApertureRegion;
334 
335     unsigned char*	MapBase;
336     unsigned char*	BciMem;
337     unsigned char*	FBBase;
338     unsigned char*	ApertureMap;
339     unsigned char*	FBStart;
340     CARD32 volatile *	ShadowVirtual;
341 
342     Bool		PrimaryVidMapped;
343     int			maxClock;
344     int			HorizScaleFactor;
345     int			MCLK, REFCLK, LCDclk;
346     double		refclk_fact;
347     int			GEResetCnt;
348 
349     /* Here are all the Options */
350 
351     OptionInfoPtr	Options;
352     Bool		IgnoreEDID;
353     Bool		ShowCache;
354     Bool		pci_burst;
355     Bool		NoPCIRetry;
356     Bool		fifo_conservative;
357     Bool		fifo_moderate;
358     Bool		fifo_aggressive;
359     Bool		hwcursor;
360     Bool		hwc_on;
361     Bool		NoAccel;
362     Bool		shadowFB;
363     Bool		UseBIOS;
364     int			rotate;
365     double		LCDClock;
366     Bool		ConfigShadowStatus; /* from the config */
367     Bool		ShadowStatus;       /* automatically enabled with DRI */
368     Bool		ForceShadowStatus;  /* true if explicitly set in conf */
369     Bool		CrtOnly;
370     Bool		TvOn;
371     Bool		PAL;
372     Bool		ForceInit;
373     int			iDevInfo;
374     int			iDevInfoPrim;
375 
376     Bool		FPExpansion;
377     int			PanelX;		/* panel width */
378     int			PanelY;		/* panel height */
379     int			iResX;		/* crtc X display */
380     int			iResY;		/* crtc Y display */
381     int			XFactor;	/* overlay X factor */
382     int			YFactor;	/* overlay Y factor */
383     int			displayXoffset;	/* overlay X offset */
384     int			displayYoffset;	/* overlay Y offset */
385     int			XExp1;		/* expansion ratio in x */
386     int			XExp2;
387     int			YExp1;		/* expansion ratio in x */
388     int			YExp2;
389     int			cxScreen;
390     int			TVSizeX;
391     int			TVSizeY;
392 
393     CloseScreenProcPtr	CloseScreen;
394 #ifdef XSERVER_LIBPCIACCESS
395     struct pci_device * PciInfo;
396 #else
397     pciVideoPtr		PciInfo;
398     PCITAG		PciTag;
399 #endif
400     int			Chipset;
401     int			ChipId;
402     int			ChipRev;
403     vbeInfoPtr		pVbe;
404     int			EntityIndex;
405     int			ShadowCounter;
406     int			vgaIOBase;	/* 3b0 or 3d0 */
407 
408     /* The various Savage wait handlers. */
409     int			(*WaitQueue)(struct _Savage *, int);
410     int			(*WaitIdle)(struct _Savage *);
411     int			(*WaitIdleEmpty)(struct _Savage *);
412 
413     /* Support for shadowFB and rotation */
414     unsigned char *	ShadowPtr;
415     int			ShadowPitch;
416     void		(*PointerMoved)(SCRN_ARG_TYPE arg, int x, int y);
417 
418     /* support for EXA */
419     ExaDriverPtr        EXADriverPtr;
420     Bool		useEXA;
421     unsigned long	EXAendfb;
422     unsigned long 	pbd_offset;
423     unsigned long	sbd_offset;
424     unsigned long	pbd_high;
425     unsigned long	sbd_high;
426 
427     /* Support for XAA acceleration */
428 #ifdef HAVE_XAA_H
429     XAAInfoRecPtr	AccelInfoRec;
430 #endif
431     xRectangle		Rect;
432     unsigned int	SavedBciCmd;
433     unsigned int	SavedFgColor;
434     unsigned int	SavedBgColor;
435     unsigned int	SavedSbdOffset;
436     unsigned int	SavedSbd;
437 
438     SavageModeTablePtr	ModeTable;
439 
440     /* Support for the Savage command overflow buffer. */
441     unsigned long	cobIndex;	/* size index */
442     unsigned long	cobSize;	/* size in bytes */
443     unsigned long	cobOffset;	/* offset in frame buffer */
444     unsigned long       bciThresholdLo; /* low and high thresholds for */
445     unsigned long       bciThresholdHi; /* shadow status update (32bit words) */
446     unsigned long	bciUsedMask;	/* BCI entries used mask */
447     unsigned int	eventStatusReg; /* Status register index that holds
448 					 * event counter 0. */
449 
450     /* Support for DGA */
451     int			numDGAModes;
452     DGAModePtr		DGAModes;
453     Bool		DGAactive;
454     int			DGAViewportStatus;
455 
456     /* Support for XVideo */
457 
458     unsigned int	videoFlags;
459     unsigned int	blendBase;
460     int			videoFourCC;
461     XF86VideoAdaptorPtr	adaptor;
462     int			VideoZoomMax;
463     int			dwBCIWait2DIdle;
464     XF86OffscreenImagePtr offscreenImages;
465 
466     /* Support for Overlays */
467      unsigned char *	FBStart2nd;
468      savageOverlayRec	overlay;
469      int                 overlayDepth;
470      int			primStreamBpp;
471 
472 #ifdef SAVAGEDRI
473     int 		LockHeld;
474     Bool 		directRenderingEnabled;
475     DRIInfoPtr 		pDRIInfo;
476     int 		drmFD;
477     int 		numVisualConfigs;
478     __GLXvisualConfig*	pVisualConfigs;
479     SAVAGEConfigPrivPtr 	pVisualConfigsPriv;
480     SAVAGEDRIServerPrivatePtr DRIServerInfo;
481     ScreenWakeupHandlerProcPtr coreWakeupHandler;
482     ScreenBlockHandlerProcPtr  coreBlockHandler;
483 
484 #if 0
485     Bool		haveQuiescense;
486     void		(*GetQuiescence)(ScrnInfoPtr pScrn);
487 #endif
488 
489     Bool		IsPCI;
490     Bool		AgpDMA;
491     Bool		VertexDMA;
492     Bool		CommandDMA;
493     int 		agpMode;
494     drmSize		agpSize;
495     FBLinearPtr		reserved;
496 
497     unsigned int surfaceAllocation[7];
498     unsigned int xvmcContext;
499     unsigned int DRIrunning;
500     unsigned int hwmcOffset;
501     unsigned int hwmcSize;
502 
503     Bool bDisableXvMC;
504 
505     Bool AGPforXv;
506 #endif
507 
508     Bool disableCOB;
509     Bool BCIforXv;
510 
511     /* Bitmap Descriptors for BCI */
512     BMPDESC GlobalBD;
513     BMPDESC PrimaryBD;
514     BMPDESC SecondBD;
515     /* do we disable tile mode by option? */
516     Bool bDisableTile;
517     /* if we enable tile,we only support tile under 16/32bpp */
518     Bool bTiled;
519     int  lDelta;
520     int  ulAperturePitch; /* aperture pitch */
521 
522     /*
523      * cxMemory is number of pixels across screen width
524      * cyMemory is number of scanlines in available adapter memory.
525      *
526      * cxMemory * cyMemory is used to determine how much memory to
527      * allocate to our heap manager.  So make sure that any space at the
528      * end of video memory set aside at bInitializeHardware time is kept
529      * out of the cyMemory calculation.
530      */
531     int cxMemory,cyMemory;
532 
533     StatInfoRec     StatInfo; /* save the SVGA state */
534 
535     /* for dvi option */
536     Bool  dvi;
537 
538     SavageMonitorType   DisplayType;
539     /* DuoView stuff */
540     Bool		HasCRTC2;     /* MX, IX, Supersavage */
541     Bool		IsSecondary;  /* second Screen */
542     Bool		IsPrimary;  /* first Screen */
543     EntityInfoPtr       pEnt;
544 
545 } SavageRec, *SavagePtr;
546 
547 /* Video flags. */
548 
549 #define VF_STREAMS_ON	0x0001
550 
551 #define SAVPTR(p)	((SavagePtr)((p)->driverPrivate))
552 
553 /* Make the names of these externals driver-unique */
554 #define gpScrn savagegpScrn
555 #define readdw savagereaddw
556 #define readfb savagereadfb
557 #define writedw savagewritedw
558 #define writefb savagewritefb
559 #define writescan savagewritescan
560 
561 /* add for support DRI */
562 #ifdef SAVAGEDRI
563 
564 #define SAVAGE_FRONT	0x1
565 #define SAVAGE_BACK	0x2
566 #define SAVAGE_DEPTH	0x4
567 #define SAVAGE_STENCIL	0x8
568 
569 Bool SAVAGEDRIScreenInit( ScreenPtr pScreen );
570 Bool SAVAGEInitMC(ScreenPtr pScreen);
571 void SAVAGEDRICloseScreen( ScreenPtr pScreen );
572 Bool SAVAGEDRIFinishScreenInit( ScreenPtr pScreen );
573 void SAVAGEDRIResume( ScreenPtr pScreen );
574 
575 #define SAVAGE_AGP_1X_MODE		0x01
576 #define SAVAGE_AGP_2X_MODE		0x02
577 #define SAVAGE_AGP_4X_MODE		0x04
578 #define SAVAGE_AGP_MODE_MASK	0x07
579 
580 #endif
581 
582 
583 /* Prototypes. */
584 
585 extern void SavageCommonCalcClock(long freq, int min_m, int min_n1,
586 			int max_n1, int min_n2, int max_n2,
587 			long freq_min, long freq_max,
588 			unsigned char *mdiv, unsigned char *ndiv);
589 void SavageAdjustFrame(ADJUST_FRAME_ARGS_DECL);
590 void SavageDoAdjustFrame(ScrnInfoPtr pScrn, int y, int x, int crtc2);
591 Bool SavageSwitchMode(SWITCH_MODE_ARGS_DECL);
592 
593 /* In savage_cursor.c. */
594 
595 Bool SavageHWCursorInit(ScreenPtr pScreen);
596 void SavageShowCursor(ScrnInfoPtr);
597 void SavageHideCursor(ScrnInfoPtr);
598 
599 /* In savage_accel.c. */
600 
601 Bool SavageInitAccel(ScreenPtr);
602 void SavageInitialize2DEngine(ScrnInfoPtr);
603 void SavageSetGBD(ScrnInfoPtr);
604 void SavageAccelSync(ScrnInfoPtr);
605 /*int SavageHelpSolidROP(ScrnInfoPtr pScrn, int *fg, int pm, int *rop);*/
606 
607 /* XAA and EXA */
608 Bool SavageXAAInit(ScreenPtr);
609 Bool SavageEXAInit(ScreenPtr);
610 
611 /* In savage_i2c.c. */
612 
613 Bool SavageI2CInit(ScrnInfoPtr pScrn);
614 
615 /* In savage_shadow.c */
616 
617 void SavagePointerMoved(SCRN_ARG_TYPE arg, int x, int y);
618 void SavageRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
619 void SavageRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
620 void SavageRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
621 void SavageRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
622 void SavageRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
623 
624 /* In savage_vbe.c */
625 
626 void SavageSetTextMode( SavagePtr psav );
627 void SavageSetVESAMode( SavagePtr psav, int n, int Refresh );
628 void SavageSetPanelEnabled( SavagePtr psav, Bool active );
629 void SavageFreeBIOSModeTable( SavagePtr psav, SavageModeTablePtr* ppTable );
630 SavageModeTablePtr SavageGetBIOSModeTable( SavagePtr psav, int iDepth );
631 ModeStatus SavageMatchBiosMode(ScrnInfoPtr pScrn,int width,int height,int refresh,
632                               unsigned int *vesaMode,unsigned int *newRefresh);
633 
634 unsigned short SavageGetBIOSModes(
635     SavagePtr psav,
636     VbeInfoBlock *vbe,
637     int iDepth,
638     SavageModeEntryPtr s3vModeTable );
639 
640 /* In savage_video.c */
641 
642 void SavageInitVideo( ScreenPtr pScreen );
643 
644 /* In savage_streams.c */
645 
646 void SavageStreamsOn(ScrnInfoPtr pScrn);
647 void SavageStreamsOff(ScrnInfoPtr pScrn);
648 void SavageInitSecondaryStream(ScrnInfoPtr pScrn);
649 void SavageInitStreamsOld(ScrnInfoPtr pScrn);
650 void SavageInitStreamsNew(ScrnInfoPtr pScrn);
651 void SavageInitStreams2000(ScrnInfoPtr pScrn);
652 
653 
654 #if (MODE_24 == 32)
655 # define  BYTES_PP24 4
656 #else
657 # define BYTES_PP24 3
658 #endif
659 
660 
661 #define DEPTH_BPP(depth) (depth == 24 ? (BYTES_PP24 << 3) : (depth + 7) & ~0x7)
662 #define DEPTH_2ND(pScrn) (pScrn->depth > 8 ? pScrn->depth\
663                               : SAVPTR(pScrn)->overlayDepth)
664 
665 #endif /* SAVAGE_DRIVER_H */
666 
667