1 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c,v 1.32 2003/08/29 08:50:54 twini Exp $ */
3 * DRI wrapper for 300 and 315 series
5 * Preliminary 315/330 support by Thomas Winischhofer
6 * Mesa 4/5 changes by Eric Anholt
8 * Taken and modified from tdfx_dri.c, mga_dri.c
13 #include "xf86_OSproc.h"
14 #include "xf86_ansic.h"
17 #include "xf86PciInfo.h"
21 #include "GL/glxtokens.h"
25 #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0)
26 #include "xf86drmCompat.h"
29 #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0)
30 #include "sis_common.h"
33 /* Idle function for 300 series */
34 #define BR(x) (0x8200 | (x) << 2)
36 while((MMIO_IN16(pSiS->IOBase, BR(16)+2) & 0xE000) != 0xE000){}; \
37 while((MMIO_IN16(pSiS->IOBase, BR(16)+2) & 0xE000) != 0xE000){}; \
38 MMIO_IN16(pSiS->IOBase, 0x8240);
40 /* Idle function for 315/330 series */
41 #define Q_STATUS 0x85CC
44 while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000){}; \
45 while( (MMIO_IN16(pSiS->IOBase, Q_STATUS+2) & 0x8000) != 0x8000){}; \
49 extern void GlxSetVisualConfigs(
51 __GLXvisualConfig
*configs
,
55 #define AGP_PAGE_SIZE 4096
56 #define AGP_PAGES 2048
57 #define AGP_SIZE (AGP_PAGE_SIZE * AGP_PAGES)
58 #define AGP_CMDBUF_PAGES 256
59 #define AGP_CMDBUF_SIZE (AGP_PAGE_SIZE * AGP_CMDBUF_PAGES)
62 #define AGP_VTXBUF_PAGES 512
63 #define AGP_VTXBUF_SIZE (AGP_PAGE_SIZE * AGP_VTXBUF_PAGES)
65 static char SISKernelDriverName
[] = "sis";
66 static char SISClientDriverName
[] = "sis";
68 static Bool
SISInitVisualConfigs(ScreenPtr pScreen
);
69 static Bool
SISCreateContext(ScreenPtr pScreen
, VisualPtr visual
,
70 drmContext hwContext
, void *pVisualConfigPriv
,
71 DRIContextType contextStore
);
72 static void SISDestroyContext(ScreenPtr pScreen
, drmContext hwContext
,
73 DRIContextType contextStore
);
74 static void SISDRISwapContext(ScreenPtr pScreen
, DRISyncType syncType
,
75 DRIContextType readContextType
,
76 void *readContextStore
,
77 DRIContextType writeContextType
,
78 void *writeContextStore
);
79 static void SISDRIInitBuffers(WindowPtr pWin
, RegionPtr prgn
, CARD32 index
);
80 static void SISDRIMoveBuffers(WindowPtr pParent
, DDXPointRec ptOldOrg
,
81 RegionPtr prgnSrc
, CARD32 index
);
83 #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,2,99,0,0)
84 extern Bool
drmSiSAgpInit(int driSubFD
, int offset
, int size
);
88 SISInitVisualConfigs(ScreenPtr pScreen
)
90 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
91 SISPtr pSIS
= SISPTR(pScrn
);
93 __GLXvisualConfig
*pConfigs
= 0;
94 SISConfigPrivPtr pSISConfigs
= 0;
95 SISConfigPrivPtr
*pSISConfigPtrs
= 0;
96 int i
, db
, z_stencil
, accum
;
99 if(getenv("SIS_FORCE_Z16")) {
103 switch (pScrn
->bitsPerPixel
) {
109 numConfigs
= (useZ16
) ? 8 : 16;
111 if(!(pConfigs
= (__GLXvisualConfig
*)xcalloc(sizeof(__GLXvisualConfig
),
115 if(!(pSISConfigs
= (SISConfigPrivPtr
)xcalloc(sizeof(SISConfigPrivRec
),
120 if(!(pSISConfigPtrs
= (SISConfigPrivPtr
*)xcalloc(sizeof(SISConfigPrivPtr
),
126 for(i
=0; i
<numConfigs
; i
++) pSISConfigPtrs
[i
] = &pSISConfigs
[i
];
129 for(accum
= 0; accum
<= 1; accum
++) {
130 for(z_stencil
=0; z_stencil
<(useZ16
?2:4); z_stencil
++) {
131 for(db
= 0; db
<= 1; db
++) {
132 pConfigs
[i
].vid
= -1;
133 pConfigs
[i
].class = -1;
134 pConfigs
[i
].rgba
= TRUE
;
135 pConfigs
[i
].redSize
= -1;
136 pConfigs
[i
].greenSize
= -1;
137 pConfigs
[i
].blueSize
= -1;
138 pConfigs
[i
].redMask
= -1;
139 pConfigs
[i
].greenMask
= -1;
140 pConfigs
[i
].blueMask
= -1;
141 pConfigs
[i
].alphaMask
= 0;
143 pConfigs
[i
].accumRedSize
= 16;
144 pConfigs
[i
].accumGreenSize
= 16;
145 pConfigs
[i
].accumBlueSize
= 16;
146 pConfigs
[i
].accumAlphaSize
= 16;
148 pConfigs
[i
].accumRedSize
= 0;
149 pConfigs
[i
].accumGreenSize
= 0;
150 pConfigs
[i
].accumBlueSize
= 0;
151 pConfigs
[i
].accumAlphaSize
= 0;
153 if(db
) pConfigs
[i
].doubleBuffer
= TRUE
;
154 else pConfigs
[i
].doubleBuffer
= FALSE
;
155 pConfigs
[i
].stereo
= FALSE
;
156 pConfigs
[i
].bufferSize
= -1;
159 pConfigs
[i
].depthSize
= 0;
160 pConfigs
[i
].stencilSize
= 0;
163 pConfigs
[i
].depthSize
= 16;
164 pConfigs
[i
].stencilSize
= 0;
167 pConfigs
[i
].depthSize
= 32;
168 pConfigs
[i
].stencilSize
= 0;
171 pConfigs
[i
].depthSize
= 24;
172 pConfigs
[i
].stencilSize
= 8;
175 pConfigs
[i
].auxBuffers
= 0;
176 pConfigs
[i
].level
= 0;
177 pConfigs
[i
].visualRating
= GLX_NONE_EXT
;
178 pConfigs
[i
].transparentPixel
= 0;
179 pConfigs
[i
].transparentRed
= 0;
180 pConfigs
[i
].transparentGreen
= 0;
181 pConfigs
[i
].transparentBlue
= 0;
182 pConfigs
[i
].transparentAlpha
= 0;
183 pConfigs
[i
].transparentIndex
= 0;
188 if(i
!= numConfigs
) {
189 xf86DrvMsg(pScrn
->scrnIndex
, X_ERROR
,
190 "[dri] Incorrect initialization of visuals. Disabling DRI.\n");
196 pSIS
->numVisualConfigs
= numConfigs
;
197 pSIS
->pVisualConfigs
= pConfigs
;
198 pSIS
->pVisualConfigsPriv
= pSISConfigs
;
199 GlxSetVisualConfigs(numConfigs
, pConfigs
, (void**)pSISConfigPtrs
);
204 Bool
SISDRIScreenInit(ScreenPtr pScreen
)
206 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
207 SISPtr pSIS
= SISPTR(pScrn
);
210 #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0)
211 drmVersionPtr version
;
214 pSIS
->cmdQueueLenPtrBackup
= NULL
;
216 pSIS
->cmdQ_SharedWritePortBackup
= NULL
;
219 /* Check that the GLX, DRI, and DRM modules have been loaded by testing
220 * for canonical symbols in each module. */
221 if(!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE
;
222 if(!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE
;
223 if(!xf86LoaderCheckSymbol("drmAvailable")) return FALSE
;
224 if(!xf86LoaderCheckSymbol("DRIQueryVersion")) {
225 xf86DrvMsg(pScreen
->myNum
, X_ERROR
,
226 "[dri] SISDRIScreenInit failed (libdri.a too old)\n");
230 /* Check the DRI version */
232 int major
, minor
, patch
;
233 DRIQueryVersion(&major
, &minor
, &patch
);
234 if(major
!= 4 || minor
< 0) {
235 xf86DrvMsg(pScreen
->myNum
, X_ERROR
,
236 "[dri] SISDRIScreenInit failed because of a version mismatch.\n"
237 "[dri] libDRI version is %d.%d.%d but version 4.0.x is needed.\n"
238 "[dri] Disabling DRI.\n",
239 major
, minor
, patch
);
244 pDRIInfo
= DRICreateInfoRec();
245 if (!pDRIInfo
) return FALSE
;
246 pSIS
->pDRIInfo
= pDRIInfo
;
248 pDRIInfo
->drmDriverName
= SISKernelDriverName
;
249 pDRIInfo
->clientDriverName
= SISClientDriverName
;
250 pDRIInfo
->busIdString
= xalloc(64);
251 sprintf(pDRIInfo
->busIdString
, "PCI:%d:%d:%d",
252 ((pciConfigPtr
)pSIS
->PciInfo
->thisCard
)->busnum
,
253 ((pciConfigPtr
)pSIS
->PciInfo
->thisCard
)->devnum
,
254 ((pciConfigPtr
)pSIS
->PciInfo
->thisCard
)->funcnum
);
255 /* Hack to keep old DRI working -- checked for major==1 and
259 pDRIInfo
->ddxDriverMajorVersion
= SIS_MAJOR_VERSION
;
260 pDRIInfo
->ddxDriverMinorVersion
= SIS_MINOR_VERSION
;
261 pDRIInfo
->ddxDriverPatchVersion
= SIS_PATCHLEVEL
;
263 pDRIInfo
->ddxDriverMajorVersion
= 0;
264 pDRIInfo
->ddxDriverMinorVersion
= 1;
265 pDRIInfo
->ddxDriverPatchVersion
= 0;
268 pDRIInfo
->frameBufferPhysicalAddress
= pSIS
->FbAddress
;
270 /* TW: This was FbMapSize which is wrong as we must not
271 * ever overwrite HWCursor and TQ area. On the other
272 * hand, using availMem here causes MTRR allocation
273 * to fail ("base is not aligned to size"). Since
274 * DRI memory management is done via framebuffer
275 * device, I assume that the size given here
276 * is NOT used for eventual memory management.
278 pDRIInfo
->frameBufferSize
= pSIS
->FbMapSize
; /* availMem; */
280 /* TW: scrnOffset is being calulated in sis_vga.c */
281 pDRIInfo
->frameBufferStride
= pSIS
->scrnOffset
;
283 pDRIInfo
->ddxDrawableTableEntry
= SIS_MAX_DRAWABLES
;
285 if(SAREA_MAX_DRAWABLES
< SIS_MAX_DRAWABLES
)
286 pDRIInfo
->maxDrawableTableEntry
= SAREA_MAX_DRAWABLES
;
288 pDRIInfo
->maxDrawableTableEntry
= SIS_MAX_DRAWABLES
;
291 /* FIXME need to extend DRI protocol to pass this size back to client
292 * for SAREA mapping that includes a device private record
294 pDRIInfo
->SAREASize
=
295 ((sizeof(XF86DRISAREARec
) + getpagesize() - 1) & getpagesize()); /* round to page */
296 /* ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); */ /* round to page */
297 /* + shared memory device private rec */
299 /* For now the mapping works by using a fixed size defined
300 * in the SAREA header
302 if(sizeof(XF86DRISAREARec
)+sizeof(SISSAREAPriv
) > SAREA_MAX
) {
303 xf86DrvMsg(pScrn
->scrnIndex
, X_ERROR
,
304 "Data does not fit in SAREA\n");
307 pDRIInfo
->SAREASize
= SAREA_MAX
;
310 if(!(pSISDRI
= (SISDRIPtr
)xcalloc(sizeof(SISDRIRec
),1))) {
311 DRIDestroyInfoRec(pSIS
->pDRIInfo
);
315 pDRIInfo
->devPrivate
= pSISDRI
;
316 pDRIInfo
->devPrivateSize
= sizeof(SISDRIRec
);
317 pDRIInfo
->contextSize
= sizeof(SISDRIContextRec
);
319 pDRIInfo
->CreateContext
= SISCreateContext
;
320 pDRIInfo
->DestroyContext
= SISDestroyContext
;
321 pDRIInfo
->SwapContext
= SISDRISwapContext
;
322 pDRIInfo
->InitBuffers
= SISDRIInitBuffers
;
323 pDRIInfo
->MoveBuffers
= SISDRIMoveBuffers
;
324 pDRIInfo
->bufferRequests
= DRI_ALL_WINDOWS
;
326 if(!DRIScreenInit(pScreen
, pDRIInfo
, &pSIS
->drmSubFD
)) {
327 xf86DrvMsg(pScreen
->myNum
, X_ERROR
,
328 "[dri] DRIScreenInit failed. Disabling DRI.\n");
329 xfree(pDRIInfo
->devPrivate
);
330 pDRIInfo
->devPrivate
= 0;
331 DRIDestroyInfoRec(pSIS
->pDRIInfo
);
337 #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0)
338 /* Check DRM kernel version */
339 version
= drmGetVersion(pSIS
->drmSubFD
);
341 if(version
->version_major
!= 1 ||
342 version
->version_minor
< 0) {
343 /* incompatible drm version */
344 xf86DrvMsg(pScreen
->myNum
, X_ERROR
,
345 "[dri] SISDRIScreenInit failed because of a version mismatch.\n"
346 "\t[dri] sis.o kernel module version is %d.%d.%d but version 1.0.x is needed.\n"
347 "\t[dri] Disabling the DRI.\n",
348 version
->version_major
,
349 version
->version_minor
,
350 version
->version_patchlevel
);
351 drmFreeVersion(version
);
352 SISDRICloseScreen(pScreen
);
355 if(version
->version_minor
>= 1) {
356 /* Includes support for framebuffer memory allocation without sisfb */
358 fb
.offset
= pSIS
->DRIheapstart
;
359 fb
.size
= pSIS
->DRIheapend
- pSIS
->DRIheapstart
;
360 drmCommandWrite(pSIS
->drmSubFD
, DRM_SIS_FB_INIT
, &fb
, sizeof(fb
));
361 xf86DrvMsg(pScreen
->myNum
, X_INFO
,
362 "[dri] DRI video RAM memory heap: 0x%x to 0x%x (%dKB)\n",
363 pSIS
->DRIheapstart
, pSIS
->DRIheapend
,
364 (pSIS
->DRIheapend
- pSIS
->DRIheapstart
) >> 10);
366 drmFreeVersion(version
);
370 pSISDRI
->regs
.size
= SISIOMAPSIZE
;
371 pSISDRI
->regs
.map
= 0;
372 if(drmAddMap(pSIS
->drmSubFD
, (drmHandle
)pSIS
->IOAddress
,
373 pSISDRI
->regs
.size
, DRM_REGISTERS
, 0,
374 &pSISDRI
->regs
.handle
) < 0) {
375 SISDRICloseScreen(pScreen
);
379 xf86DrvMsg(pScreen
->myNum
, X_INFO
, "[drm] Registers = 0x%08lx\n",
380 pSISDRI
->regs
.handle
);
385 pSIS
->agpCmdBufSize
= 0;
386 pSISDRI
->AGPCmdBufSize
= 0;
391 if(drmAgpAcquire(pSIS
->drmSubFD
) < 0) {
392 xf86DrvMsg(pScreen
->myNum
, X_ERROR
, "[drm] drmAgpAcquire failed\n");
396 if(pSIS
->VGAEngine
== SIS_315_VGA
) {
398 /* Default to 1X agp mode in SIS315 */
399 if(drmAgpEnable(pSIS
->drmSubFD
, drmAgpGetMode(pSIS
->drmSubFD
) & ~0x00000002) < 0) {
400 xf86DrvMsg(pScreen
->myNum
, X_ERROR
, "[drm] drmAgpEnable failed\n");
405 /* TODO: default value is 2x? */
406 if(drmAgpEnable(pSIS
->drmSubFD
, drmAgpGetMode(pSIS
->drmSubFD
) & ~0x0) < 0) {
407 xf86DrvMsg(pScreen
->myNum
, X_ERROR
, "[drm] drmAgpEnable failed\n");
412 xf86DrvMsg(pScreen
->myNum
, X_INFO
, "[drm] drmAgpEnabled succeeded\n");
414 if(drmAgpAlloc(pSIS
->drmSubFD
, AGP_SIZE
, 0, NULL
, &pSIS
->agpHandle
) < 0) {
415 xf86DrvMsg(pScreen
->myNum
, X_ERROR
, "[drm] drmAgpAlloc failed\n");
416 drmAgpRelease(pSIS
->drmSubFD
);
420 if(drmAgpBind(pSIS
->drmSubFD
, pSIS
->agpHandle
, 0) < 0) {
421 xf86DrvMsg(pScreen
->myNum
, X_ERROR
, "[drm] drmAgpBind failed\n");
422 drmAgpFree(pSIS
->drmSubFD
, pSIS
->agpHandle
);
423 drmAgpRelease(pSIS
->drmSubFD
);
427 pSIS
->agpSize
= AGP_SIZE
;
428 pSIS
->agpAddr
= drmAgpBase(pSIS
->drmSubFD
);
429 /* pSIS->agpBase = */
431 pSISDRI
->agp
.size
= pSIS
->agpSize
;
432 if(drmAddMap(pSIS
->drmSubFD
, (drmHandle
)0,
433 pSISDRI
->agp
.size
, DRM_AGP
, 0,
434 &pSISDRI
->agp
.handle
) < 0) {
435 xf86DrvMsg(pScreen
->myNum
, X_ERROR
,
436 "[drm] Failed to map public agp area\n");
437 pSISDRI
->agp
.size
= 0;
441 if(pSIS
->VGAEngine
== SIS_315_VGA
) {
443 pSIS
->agpVtxBufSize
= AGP_VTXBUF_SIZE
; /* = 2MB */
444 pSIS
->agpVtxBufAddr
= pSIS
->agpAddr
;
445 pSIS
->agpVtxBufBase
= pSIS
->agpVtxBufAddr
- pSIS
->agpAddr
+ pSIS
->agpBase
;
446 pSIS
->agpVtxBufFree
= 0;
448 pSISDRI
->AGPVtxBufOffset
= pSIS
->agpVtxBufAddr
- pSIS
->agpAddr
;
449 pSISDRI
->AGPVtxBufSize
= pSIS
->agpVtxBufSize
;
451 drmSiSAgpInit(pSIS
->drmSubFD
, AGP_VTXBUF_SIZE
,(AGP_SIZE
- AGP_VTXBUF_SIZE
));
455 pSIS
->agpCmdBufSize
= AGP_CMDBUF_SIZE
;
456 pSIS
->agpCmdBufAddr
= pSIS
->agpAddr
;
457 pSIS
->agpCmdBufBase
= pSIS
->agpCmdBufAddr
- pSIS
->agpAddr
+ pSIS
->agpBase
;
458 pSIS
->agpCmdBufFree
= 0;
460 pSISDRI
->AGPCmdBufOffset
= pSIS
->agpCmdBufAddr
- pSIS
->agpAddr
;
461 pSISDRI
->AGPCmdBufSize
= pSIS
->agpCmdBufSize
;
463 drmSiSAgpInit(pSIS
->drmSubFD
, AGP_CMDBUF_SIZE
,(AGP_SIZE
- AGP_CMDBUF_SIZE
));
469 pSIS
->irq
= drmGetInterruptFromBusID(pSIS
->drmSubFD
,
470 ((pciConfigPtr
)pSIS
->PciInfo
->thisCard
)->busnum
,
471 ((pciConfigPtr
)pSIS
->PciInfo
->thisCard
)->devnum
,
472 ((pciConfigPtr
)pSIS
->PciInfo
->thisCard
)->funcnum
);
474 if((drmCtlInstHandler(pSIS
->drmSubFD
, pSIS
->irq
)) != 0) {
475 xf86DrvMsg(pScrn
->scrnIndex
, X_INFO
,
476 "[drm] failure adding irq %d handler, stereo disabled\n",
478 pSIS
->irqEnabled
= FALSE
;
480 pSIS
->irqEnabled
= TRUE
;
483 pSISDRI
->irqEnabled
= pSIS
->irqEnabled
;
485 if(!(SISInitVisualConfigs(pScreen
))) {
486 SISDRICloseScreen(pScreen
);
490 xf86DrvMsg(pScrn
->scrnIndex
, X_INFO
, "[dri] visual configs initialized.\n" );
496 SISDRICloseScreen(ScreenPtr pScreen
)
498 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
499 SISPtr pSIS
= SISPTR(pScrn
);
501 if(pSIS
->VGAEngine
== SIS_315_VGA
) {
503 if(pSIS
->cmdQ_SharedWritePortBackup
) {
504 pSIS
->cmdQ_SharedWritePort
= pSIS
->cmdQ_SharedWritePortBackup
;
508 if(pSIS
->cmdQueueLenPtrBackup
) {
509 pSIS
->cmdQueueLenPtr
= pSIS
->cmdQueueLenPtrBackup
;
510 *(pSIS
->cmdQueueLenPtr
) = 0;
514 DRICloseScreen(pScreen
);
517 if(pSIS
->pDRIInfo
->devPrivate
) {
518 xfree(pSIS
->pDRIInfo
->devPrivate
);
519 pSIS
->pDRIInfo
->devPrivate
=0;
521 DRIDestroyInfoRec(pSIS
->pDRIInfo
);
524 if(pSIS
->pVisualConfigs
) xfree(pSIS
->pVisualConfigs
);
525 if(pSIS
->pVisualConfigsPriv
) xfree(pSIS
->pVisualConfigsPriv
);
528 xf86DrvMsg(pScreen
->myNum
, X_INFO
, "[drm] Freeing agp memory\n");
529 drmAgpFree(pSIS
->drmSubFD
, pSIS
->agpHandle
);
530 xf86DrvMsg(pScreen
->myNum
, X_INFO
, "[drm] Releasing agp module\n");
531 drmAgpRelease(pSIS
->drmSubFD
);
535 /* TODO: xserver receives driver's swapping event and do something
536 * according the data initialized in this function
539 SISCreateContext(ScreenPtr pScreen
, VisualPtr visual
,
540 drmContext hwContext
, void *pVisualConfigPriv
,
541 DRIContextType contextStore
)
547 SISDestroyContext(ScreenPtr pScreen
, drmContext hwContext
,
548 DRIContextType contextStore
)
553 SISDRIFinishScreenInit(ScreenPtr pScreen
)
555 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
556 SISPtr pSiS
= SISPTR(pScrn
);
559 pSiS
->pDRIInfo
->driverSwapMethod
= DRI_HIDE_X_CONTEXT
;
560 /* pSiS->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */
562 pSISDRI
=(SISDRIPtr
)pSiS
->pDRIInfo
->devPrivate
;
563 pSISDRI
->deviceID
=pSiS
->Chipset
;
564 pSISDRI
->width
=pScrn
->virtualX
;
565 pSISDRI
->height
=pScrn
->virtualY
;
566 pSISDRI
->mem
=pScrn
->videoRam
*1024;
567 pSISDRI
->bytesPerPixel
= (pScrn
->bitsPerPixel
+7) / 8;
569 pSISDRI
->scrnX
=pSISDRI
->width
;
570 pSISDRI
->scrnY
=pSISDRI
->height
;
573 pSISDRI->textureOffset=pSiS->texOffset;
574 pSISDRI->textureSize=pSiS->texSize;
575 pSISDRI->fbOffset=pSiS->fbOffset;
576 pSISDRI->backOffset=pSiS->backOffset;
577 pSISDRI->depthOffset=pSiS->depthOffset;
580 /* set SAREA value */
582 SISSAREAPriv
*saPriv
;
584 saPriv
= (SISSAREAPriv
*)DRIGetSAREAPrivate(pScreen
);
588 saPriv
->CtxOwner
= -1;
589 saPriv
->QueueLength
= *(pSiS
->cmdQueueLenPtr
);
590 pSiS
->cmdQueueLenPtrBackup
= pSiS
->cmdQueueLenPtr
;
591 pSiS
->cmdQueueLenPtr
= &(saPriv
->QueueLength
);
593 if(pSiS
->VGAEngine
== SIS_315_VGA
) {
595 saPriv
->AGPVtxBufNext
= 0;
596 saPriv
->sharedWPoffset
= pSiS
->cmdQ_SharedWritePort_2D
;
597 pSiS
->cmdQ_SharedWritePortBackup
= pSiS
->cmdQ_SharedWritePort
;
598 pSiS
->cmdQ_SharedWritePort
= &(saPriv
->sharedWPoffset
);
601 saPriv
->AGPCmdBufNext
= 0;
604 saPriv
->FrameCount
= 0;
605 *(unsigned long *)(pSiS
->IOBase
+0x8a2c) = 0;
610 return DRIFinishScreenInit(pScreen
);
614 SISDRISwapContext(ScreenPtr pScreen
, DRISyncType syncType
,
615 DRIContextType oldContextType
, void *oldContext
,
616 DRIContextType newContextType
, void *newContext
)
618 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
619 SISPtr pSiS
= SISPTR(pScrn
);
622 if ((syncType
==DRI_3D_SYNC
) && (oldContextType
==DRI_2D_CONTEXT
) &&
623 (newContextType
==DRI_2D_CONTEXT
)) { /* Entering from Wakeup */
624 SISSwapContextPrivate(pScreen
);
626 if ((syncType
==DRI_2D_SYNC
) && (oldContextType
==DRI_NO_CONTEXT
) &&
627 (newContextType
==DRI_2D_CONTEXT
)) { /* Exiting from Block Handler */
628 SISLostContext(pScreen
);
634 * TODO: do this only if X-Server get lock. If kernel supports delayed
635 * signal, needless to do this
637 if(pSiS
->VGAEngine
== SIS_315_VGA
) {
642 *(pSiS
->IOBase
+ 0x8B50) = 0xff;
643 *(unsigned int *)(pSiS
->IOBase
+ 0x8B60) = -1;
648 SISDRIInitBuffers(WindowPtr pWin
, RegionPtr prgn
, CARD32 index
)
650 ScreenPtr pScreen
= pWin
->drawable
.pScreen
;
651 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
652 SISPtr pSiS
= SISPTR(pScrn
);
654 if(pSiS
->VGAEngine
== SIS_315_VGA
) {
656 SiS315Idle
/* 315 series */
659 SiSIdle
/* 300 series */
664 SISDRIMoveBuffers(WindowPtr pParent
, DDXPointRec ptOldOrg
,
665 RegionPtr prgnSrc
, CARD32 index
)
667 ScreenPtr pScreen
= pParent
->drawable
.pScreen
;
668 ScrnInfoPtr pScrn
= xf86Screens
[pScreen
->myNum
];
669 SISPtr pSiS
= SISPTR(pScrn
);
671 if(pSiS
->VGAEngine
== SIS_315_VGA
) {
673 SiS315Idle
/* 315 series */
676 SiSIdle
/* 300 series */
681 void SISLostContext(ScreenPtr pScreen
)
685 void SISSwapContextPrivate(ScreenPtr pScreen
)