DRI XFree86-4_3_99_12-merge import
[xf86-video-sis/mirage.git] / src / sis_dri.c
blob08e17b37315e5351d117f2400114c3857f37adb0
1 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.c,v 1.32 2003/08/29 08:50:54 twini Exp $ */
2 /*
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
12 #include "xf86.h"
13 #include "xf86_OSproc.h"
14 #include "xf86_ansic.h"
15 #include "xf86Priv.h"
17 #include "xf86PciInfo.h"
18 #include "xf86Pci.h"
19 #include "fb.h"
21 #include "GL/glxtokens.h"
23 #include "sis.h"
24 #include "sis_dri.h"
25 #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,2,99,0,0)
26 #include "xf86drmCompat.h"
27 #endif
29 #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0)
30 #include "sis_common.h"
31 #endif
33 /* Idle function for 300 series */
34 #define BR(x) (0x8200 | (x) << 2)
35 #define SiSIdle \
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
42 #define SiS315Idle \
43 { \
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(
50 int nconfigs,
51 __GLXvisualConfig *configs,
52 void **configprivs
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)
61 /* 315/330 */
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);
85 #endif
87 static Bool
88 SISInitVisualConfigs(ScreenPtr pScreen)
90 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
91 SISPtr pSIS = SISPTR(pScrn);
92 int numConfigs = 0;
93 __GLXvisualConfig *pConfigs = 0;
94 SISConfigPrivPtr pSISConfigs = 0;
95 SISConfigPrivPtr *pSISConfigPtrs = 0;
96 int i, db, z_stencil, accum;
97 Bool useZ16 = FALSE;
99 if(getenv("SIS_FORCE_Z16")) {
100 useZ16 = TRUE;
103 switch (pScrn->bitsPerPixel) {
104 case 8:
105 case 24:
106 break;
107 case 16:
108 case 32:
109 numConfigs = (useZ16) ? 8 : 16;
111 if(!(pConfigs = (__GLXvisualConfig*)xcalloc(sizeof(__GLXvisualConfig),
112 numConfigs))) {
113 return FALSE;
115 if(!(pSISConfigs = (SISConfigPrivPtr)xcalloc(sizeof(SISConfigPrivRec),
116 numConfigs))) {
117 xfree(pConfigs);
118 return FALSE;
120 if(!(pSISConfigPtrs = (SISConfigPrivPtr*)xcalloc(sizeof(SISConfigPrivPtr),
121 numConfigs))) {
122 xfree(pConfigs);
123 xfree(pSISConfigs);
124 return FALSE;
126 for(i=0; i<numConfigs; i++) pSISConfigPtrs[i] = &pSISConfigs[i];
128 i = 0;
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;
142 if(accum) {
143 pConfigs[i].accumRedSize = 16;
144 pConfigs[i].accumGreenSize = 16;
145 pConfigs[i].accumBlueSize = 16;
146 pConfigs[i].accumAlphaSize = 16;
147 } else {
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;
157 switch(z_stencil) {
158 case 0:
159 pConfigs[i].depthSize = 0;
160 pConfigs[i].stencilSize = 0;
161 break;
162 case 1:
163 pConfigs[i].depthSize = 16;
164 pConfigs[i].stencilSize = 0;
165 break;
166 case 2:
167 pConfigs[i].depthSize = 32;
168 pConfigs[i].stencilSize = 0;
169 break;
170 case 3:
171 pConfigs[i].depthSize = 24;
172 pConfigs[i].stencilSize = 8;
173 break;
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;
184 i++;
188 if(i != numConfigs) {
189 xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
190 "[dri] Incorrect initialization of visuals. Disabling DRI.\n");
191 return FALSE;
193 break;
196 pSIS->numVisualConfigs = numConfigs;
197 pSIS->pVisualConfigs = pConfigs;
198 pSIS->pVisualConfigsPriv = pSISConfigs;
199 GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pSISConfigPtrs);
201 return TRUE;
204 Bool SISDRIScreenInit(ScreenPtr pScreen)
206 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
207 SISPtr pSIS = SISPTR(pScrn);
208 DRIInfoPtr pDRIInfo;
209 SISDRIPtr pSISDRI;
210 #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0)
211 drmVersionPtr version;
212 #endif
214 pSIS->cmdQueueLenPtrBackup = NULL;
215 #ifdef SIS315DRI
216 pSIS->cmdQ_SharedWritePortBackup = NULL;
217 #endif
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");
227 return FALSE;
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);
240 return FALSE;
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
256 * minor==1.
258 #ifdef SISNEWDRI
259 pDRIInfo->ddxDriverMajorVersion = SIS_MAJOR_VERSION;
260 pDRIInfo->ddxDriverMinorVersion = SIS_MINOR_VERSION;
261 pDRIInfo->ddxDriverPatchVersion = SIS_PATCHLEVEL;
262 #else
263 pDRIInfo->ddxDriverMajorVersion = 0;
264 pDRIInfo->ddxDriverMinorVersion = 1;
265 pDRIInfo->ddxDriverPatchVersion = 0;
266 #endif
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;
287 else
288 pDRIInfo->maxDrawableTableEntry = SIS_MAX_DRAWABLES;
290 #ifdef NOT_DONE
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 */
298 #else
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");
305 return FALSE;
307 pDRIInfo->SAREASize = SAREA_MAX;
308 #endif
310 if(!(pSISDRI = (SISDRIPtr)xcalloc(sizeof(SISDRIRec),1))) {
311 DRIDestroyInfoRec(pSIS->pDRIInfo);
312 pSIS->pDRIInfo = 0;
313 return FALSE;
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);
332 pSIS->pDRIInfo = 0;
333 pSIS->drmSubFD = -1;
334 return FALSE;
337 #if XF86_VERSION_CURRENT >= XF86_VERSION_NUMERIC(4,3,0,0,0)
338 /* Check DRM kernel version */
339 version = drmGetVersion(pSIS->drmSubFD);
340 if(version) {
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);
353 return FALSE;
355 if(version->version_minor >= 1) {
356 /* Includes support for framebuffer memory allocation without sisfb */
357 drm_sis_fb_t fb;
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);
368 #endif
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);
376 return FALSE;
379 xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n",
380 pSISDRI->regs.handle);
382 /* AGP */
383 do {
384 pSIS->agpSize = 0;
385 pSIS->agpCmdBufSize = 0;
386 pSISDRI->AGPCmdBufSize = 0;
388 if(!pSIS->IsAGPCard)
389 break;
391 if(drmAgpAcquire(pSIS->drmSubFD) < 0) {
392 xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpAcquire failed\n");
393 break;
396 if(pSIS->VGAEngine == SIS_315_VGA) {
397 #ifdef SIS315DRI
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");
401 break;
403 #endif
404 } else {
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");
408 break;
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);
417 break;
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);
424 break;
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;
438 break;
441 if(pSIS->VGAEngine == SIS_315_VGA) {
442 #ifdef SIS315DRI
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));
452 #endif
453 } else {
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));
466 while(0);
468 /* enable IRQ */
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",
477 pSIS->irq);
478 pSIS->irqEnabled = FALSE;
479 } else {
480 pSIS->irqEnabled = TRUE;
483 pSISDRI->irqEnabled = pSIS->irqEnabled;
485 if(!(SISInitVisualConfigs(pScreen))) {
486 SISDRICloseScreen(pScreen);
487 return FALSE;
490 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] visual configs initialized.\n" );
492 return TRUE;
495 void
496 SISDRICloseScreen(ScreenPtr pScreen)
498 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
499 SISPtr pSIS = SISPTR(pScrn);
501 if(pSIS->VGAEngine == SIS_315_VGA) {
502 #ifdef SIS315DRI
503 if(pSIS->cmdQ_SharedWritePortBackup) {
504 pSIS->cmdQ_SharedWritePort = pSIS->cmdQ_SharedWritePortBackup;
506 #endif
507 } else {
508 if(pSIS->cmdQueueLenPtrBackup) {
509 pSIS->cmdQueueLenPtr = pSIS->cmdQueueLenPtrBackup;
510 *(pSIS->cmdQueueLenPtr) = 0;
514 DRICloseScreen(pScreen);
516 if(pSIS->pDRIInfo) {
517 if(pSIS->pDRIInfo->devPrivate) {
518 xfree(pSIS->pDRIInfo->devPrivate);
519 pSIS->pDRIInfo->devPrivate=0;
521 DRIDestroyInfoRec(pSIS->pDRIInfo);
522 pSIS->pDRIInfo=0;
524 if(pSIS->pVisualConfigs) xfree(pSIS->pVisualConfigs);
525 if(pSIS->pVisualConfigsPriv) xfree(pSIS->pVisualConfigsPriv);
527 if(pSIS->agpSize){
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
538 static Bool
539 SISCreateContext(ScreenPtr pScreen, VisualPtr visual,
540 drmContext hwContext, void *pVisualConfigPriv,
541 DRIContextType contextStore)
543 return TRUE;
546 static void
547 SISDestroyContext(ScreenPtr pScreen, drmContext hwContext,
548 DRIContextType contextStore)
552 Bool
553 SISDRIFinishScreenInit(ScreenPtr pScreen)
555 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
556 SISPtr pSiS = SISPTR(pScrn);
557 SISDRIPtr pSISDRI;
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;
568 /* TODO */
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);
586 assert(saPriv);
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) {
594 #ifdef SIS315DRI
595 saPriv->AGPVtxBufNext = 0;
596 saPriv->sharedWPoffset = pSiS->cmdQ_SharedWritePort_2D;
597 pSiS->cmdQ_SharedWritePortBackup = pSiS->cmdQ_SharedWritePort;
598 pSiS->cmdQ_SharedWritePort = &(saPriv->sharedWPoffset);
599 #endif
600 } else {
601 saPriv->AGPCmdBufNext = 0;
603 /* frame control */
604 saPriv->FrameCount = 0;
605 *(unsigned long *)(pSiS->IOBase+0x8a2c) = 0;
606 SiSIdle
610 return DRIFinishScreenInit(pScreen);
613 static void
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);
621 #if 0
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);
630 #endif
632 /* mEndPrimitive */
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) {
638 #ifdef SIS315DRI
639 /* ? */
640 #endif
641 } else {
642 *(pSiS->IOBase + 0x8B50) = 0xff;
643 *(unsigned int *)(pSiS->IOBase + 0x8B60) = -1;
647 static void
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) {
655 #ifdef SIS315DRI
656 SiS315Idle /* 315 series */
657 #endif
658 } else {
659 SiSIdle /* 300 series */
663 static void
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) {
672 #ifdef SIS315DRI
673 SiS315Idle /* 315 series */
674 #endif
675 } else {
676 SiSIdle /* 300 series */
680 #if 0
681 void SISLostContext(ScreenPtr pScreen)
685 void SISSwapContextPrivate(ScreenPtr pScreen)
688 #endif