summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellström <thomas@shipmail.org>2008-10-29 10:59:57 +0000
committerThomas Hellström <thomas@shipmail.org>2008-10-29 10:59:57 +0000
commit3fc6cce69ce0548b87fd597ce182803a21820163 (patch)
treec8e6dfcdbbe6b706161d4b0192252ca52cecca03
parent764e3dd98e107774eed66033bcf47eb0161819cc (diff)
Adapt to libwsbm synccpu interface
-rw-r--r--src/ochr_ioctl.c8
-rw-r--r--src/via_accel.c19
-rw-r--r--src/via_cursor.c8
-rw-r--r--src/via_dri.c2
-rw-r--r--src/via_driver.c37
-rw-r--r--src/via_memcpy.c2
-rw-r--r--src/via_swov.c7
-rw-r--r--src/via_video.c13
8 files changed, 57 insertions, 39 deletions
diff --git a/src/ochr_ioctl.c b/src/ochr_ioctl.c
index b83df36..221fea4 100644
--- a/src/ochr_ioctl.c
+++ b/src/ochr_ioctl.c
@@ -599,8 +599,8 @@ ochr_execbuf(int fd, struct _ViaCommandBuffer *cBuf)
*prevNext = (uint64_t) (unsigned long)val_arg;
prevNext = &req->next;
- req->buffer_handle = wsbmKbufHandle((struct _WsbmKernelBuf *)
- node->buf);
+ req->buffer_handle = wsbmKBufHandle((struct _WsbmKernelBuf *)
+ node->buf);
req->group = 0;
req->set_flags = node->set_flags;
req->clear_flags = node->clr_flags;
@@ -667,8 +667,8 @@ ochr_execbuf(int fd, struct _ViaCommandBuffer *cBuf)
}
rep = &val_arg->d.rep;
- wsbmUpdateKbuf((struct _WsbmKernelBuf *)node->buf,
- rep->gpu_offset, rep->placement, rep->fence_type_mask);
+ wsbmUpdateKBuf((struct _WsbmKernelBuf *)node->buf,
+ rep->gpu_offset, rep->placement, rep->fence_type_mask);
iterator = validateListNext(valList, iterator);
}
diff --git a/src/via_accel.c b/src/via_accel.c
index bc470af..7538774 100644
--- a/src/via_accel.c
+++ b/src/via_accel.c
@@ -1079,7 +1079,7 @@ viaExaUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
if (ret)
goto out_err1;
- dst = wsbmBOMap(entry->buf, 1, WSBM_SYNCCPU_WRITE);
+ dst = wsbmBOMap(entry->buf, WSBM_ACCESS_WRITE);
if (dst == NULL)
goto out_err1;
@@ -1343,7 +1343,7 @@ viaExaPrepareAccess(PixmapPtr pPix, int index)
struct _ViaOffscreenBuffer *buf;
uint32_t flags;
void *ptr;
- void *virtual;
+ int ret = 0;
ptr = (void *) (exaGetPixmapOffset(pPix) +
(unsigned long) pVia->exaMem.virtual);
@@ -1352,9 +1352,9 @@ viaExaPrepareAccess(PixmapPtr pPix, int index)
if (buf) {
flags = (index == EXA_PREPARE_DEST) ?
WSBM_SYNCCPU_WRITE : WSBM_SYNCCPU_READ;
- virtual = wsbmBOMap(buf->buf, 1, flags);
+ ret = wsbmBOSyncForCpu(buf->buf, flags);
}
- return TRUE;
+ return (ret == 0);
}
static void
@@ -1364,6 +1364,7 @@ viaExaFinishAccess(PixmapPtr pPix, int index)
VIAPtr pVia = VIAPTR(pScrn);
struct _ViaOffscreenBuffer *buf;
void *ptr;
+ uint32_t flags;
ptr = (void *) (exaGetPixmapOffset(pPix) +
(unsigned long) pVia->exaMem.virtual);
@@ -1371,7 +1372,9 @@ viaExaFinishAccess(PixmapPtr pPix, int index)
buf = viaInBuffer(&pVia->offscreen, ptr);
if (buf) {
- (void) wsbmBOUnmap(buf->buf);
+ flags = (index == EXA_PREPARE_DEST) ?
+ WSBM_SYNCCPU_WRITE : WSBM_SYNCCPU_READ;
+ (void) wsbmBOReleaseFromCpu(buf->buf, flags);
}
}
@@ -1494,14 +1497,13 @@ viaInitAccel(ScreenPtr pScreen)
goto out_err0;
}
- pVia->exaMem.virtual = wsbmBOMap(pVia->exaMem.buf, 1,
- WSBM_SYNCCPU_READ | WSBM_SYNCCPU_WRITE);
+ pVia->exaMem.virtual = wsbmBOMap(pVia->exaMem.buf,
+ WSBM_SYNCCPU_READ | WSBM_SYNCCPU_WRITE);
if (pVia->exaMem.virtual == NULL) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"[Accel] Failed mapping offscreen pixmap space.\n");
goto out_err0;
}
- wsbmBOUnmap(pVia->exaMem.buf);
pVia->exaMem.size = wsbmBOSize(pVia->exaMem.buf);
pVia->exaMem.scratch = FALSE;
pVia->front.scratch = FALSE;
@@ -1576,6 +1578,7 @@ viaExitAccel(ScreenPtr pScreen)
viaFreeScratchBuffers(pVia);
WSBMLISTDELINIT(&pVia->front.head);
WSBMLISTDELINIT(&pVia->exaMem.head);
+ (void) wsbmBOUnmap(pVia->exaMem.buf);
wsbmDeleteBuffers(1, &pVia->exaMem.buf);
return;
}
diff --git a/src/via_cursor.c b/src/via_cursor.c
index ae060ff..e040459 100644
--- a/src/via_cursor.c
+++ b/src/via_cursor.c
@@ -71,13 +71,11 @@ VIAHWCursorInit(ScreenPtr pScreen)
if (ret)
return FALSE;
- pVia->cursorMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_CURSOR], 1,
- WSBM_SYNCCPU_READ |
- WSBM_SYNCCPU_WRITE);
-
+ pVia->cursorMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_CURSOR],
+ WSBM_ACCESS_WRITE);
if (pVia->cursorMap == NULL)
return FALSE;
- wsbmBOUnmap(pVia->scanout.bufs[VIA_SCANOUT_CURSOR]);
+
pVia->cursorOffset = wsbmBOOffset(pVia->scanout.bufs[VIA_SCANOUT_CURSOR]);
memset(pVia->cursorMap, 0x00, VIA_CURSOR_SIZE);
diff --git a/src/via_dri.c b/src/via_dri.c
index 9ca0cfd..3dff97a 100644
--- a/src/via_dri.c
+++ b/src/via_dri.c
@@ -527,7 +527,7 @@ viaDRIUpdateFront(ScreenPtr pScreen)
struct _WsbmKernelBuf *buf = wsbmKBuf(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
++front->stamp;
- front->handle = wsbmKbufHandle(buf);
+ front->handle = wsbmKBufHandle(buf);
front->width = pScrn->virtualX;
front->height = pScrn->virtualY;
front->stride = pVia->Bpl;
diff --git a/src/via_driver.c b/src/via_driver.c
index edea295..252d653 100644
--- a/src/via_driver.c
+++ b/src/via_driver.c
@@ -1805,15 +1805,14 @@ VIAEnterVT(int scrnIndex, int flags)
"Failed reallocating the display buffer.");
return FALSE;
}
- pVia->displayMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY], 1,
- WSBM_SYNCCPU_READ | WSBM_SYNCCPU_WRITE);
+ pVia->displayMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY],
+ WSBM_ACCESS_READ | WSBM_ACCESS_WRITE);
if (!pVia->displayMap) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Failed mapping display video RAM: \"%s\".\n",
strerror(-ret));
return FALSE;
}
- wsbmBOUnmap(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
pVia->front.virtual = pVia->displayMap;
pVia->front.size = wsbmBOSize(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
@@ -1829,8 +1828,8 @@ VIAEnterVT(int scrnIndex, int flags)
}
pVia->displayOffset = wsbmBOOffset(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
- pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+ pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
retVal = wsbmBOSetStatus(pVia->scanout.bufs[VIA_SCANOUT_CURSOR],
WSBM_PL_FLAG_VRAM | WSBM_PL_FLAG_NO_EVICT,
WSBM_PL_FLAG_SYSTEM);
@@ -1841,6 +1840,11 @@ VIAEnterVT(int scrnIndex, int flags)
return FALSE;
}
+ pVia->cursorMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_CURSOR],
+ WSBM_ACCESS_WRITE);
+ if (!pVia->cursorMap)
+ return FALSE;
+
pVia->cursorOffset = wsbmBOOffset(pVia->scanout.bufs[VIA_SCANOUT_CURSOR]);
/* A Patch for APM suspend/resume, when HWCursor has garbage. */
@@ -1851,7 +1855,7 @@ VIAEnterVT(int scrnIndex, int flags)
if (!pVia->IsSecondary)
viaRestoreVideo(pScrn);
- if (pVia->NoAccel) {
+ if (1) {
memset(pVia->displayMap, 0x00, pVia->Bpl * pScrn->virtualY);
} else {
viaAccelFillRect(pScrn, 0, 0, pScrn->displayWidth, pScrn->virtualY,
@@ -1876,9 +1880,9 @@ VIALeaveVT(int scrnIndex, int flags)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
VIAPtr pVia = VIAPTR(pScrn);
+ int ret;
DEBUG(xf86DrvMsg(scrnIndex, X_INFO, "VIALeaveVT\n"));
- ErrorF("Leavevt\n");
vgaHWBlankScreen(pScrn, FALSE);
@@ -1913,20 +1917,21 @@ VIALeaveVT(int scrnIndex, int flags)
* Release the scanouts.
*/
- pVia->displayMap = 0;
+ pVia->displayMap = NULL;
/*
* First move out all buffers so any DRI references won't keep them
* in VRAM.
*/
- (void) wsbmBOSetStatus(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY],
- 0,
- WSBM_PL_FLAG_NO_EVICT);
- (void) wsbmBOSetStatus(pVia->scanout.bufs[VIA_SCANOUT_CURSOR],
+ wsbmBOUnmap(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
+ ret= wsbmBOSetStatus(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY],
+ 0,
+ WSBM_PL_FLAG_NO_EVICT);
+ wsbmBOUnmap(pVia->scanout.bufs[VIA_SCANOUT_CURSOR]);
+ ret = wsbmBOSetStatus(pVia->scanout.bufs[VIA_SCANOUT_CURSOR],
0,
WSBM_PL_FLAG_NO_EVICT);
-
(void) wsbmBOData(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY],
0, NULL, NULL, 0);
@@ -2555,7 +2560,7 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pVia->front.buf = wsbmBOReference(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
pVia->displayMap = NULL;
- pVia->displayMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY], 1,
+ pVia->displayMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY],
WSBM_SYNCCPU_READ | WSBM_SYNCCPU_WRITE);
if (!pVia->displayMap) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -2564,7 +2569,6 @@ VIAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
goto out_err3;
}
- wsbmBOUnmap(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
pVia->front.virtual = pVia->displayMap;
pVia->front.size = wsbmBOSize(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
@@ -2946,6 +2950,11 @@ VIACloseScreen(int scrnIndex, ScreenPtr pScreen)
wsbmBOUnReference(pVia->front.buf);
pVia->front.buf = NULL;
+
+ wsbmBOUnmap(pVia->scanout.bufs[VIA_SCANOUT_CURSOR]);
+ pVia->displayMap = NULL;
+ wsbmBOUnmap(pVia->scanout.bufs[VIA_SCANOUT_DISPLAY]);
+ pVia->cursorMap = NULL;
wsbmDeleteBuffers(VIA_SCANOUT_NUM, pVia->scanout.bufs);
if (pVia->mainPool && !pVia->IsSecondary) {
diff --git a/src/via_memcpy.c b/src/via_memcpy.c
index 4fb9f9d..1e480d6 100644
--- a/src/via_memcpy.c
+++ b/src/via_memcpy.c
@@ -594,7 +594,7 @@ viaVidCopyInit(char *copyType, ScreenPtr pScreen)
return libc_YUV42X;
}
- buf1 = wsbmBOMap(tmpFbBuffer, 1, WSBM_SYNCCPU_WRITE);
+ buf1 = wsbmBOMap(tmpFbBuffer, WSBM_SYNCCPU_WRITE);
if (!buf1) {
wsbmDeleteBuffers(1, &tmpFbBuffer);
diff --git a/src/via_swov.c b/src/via_swov.c
index d4cece8..01fe1ab 100644
--- a/src/via_swov.c
+++ b/src/via_swov.c
@@ -956,7 +956,8 @@ AddHQVSurface(ScrnInfoPtr pScrn, unsigned int numbuf, CARD32 fourcc)
if (retCode)
return BadAlloc;
- hqvMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_OVERLAY], 1, WSBM_SYNCCPU_WRITE);
+ hqvMap = wsbmBOMap(pVia->scanout.bufs[VIA_SCANOUT_OVERLAY], WSBM_ACCESS_WRITE);
+
if (hqvMap == NULL)
return BadAlloc;
@@ -1035,10 +1036,9 @@ CreateSurface(ScrnInfoPtr pScrn, CARD32 FourCC, CARD16 Width,
if (retCode)
goto out_err;
- hqvBuf->virtual = wsbmBOMap(hqvBuf->buf, 1, WSBM_SYNCCPU_WRITE);
+ hqvBuf->virtual = wsbmBOMap(hqvBuf->buf, WSBM_ACCESS_WRITE);
if (hqvBuf->virtual == NULL)
goto out_err;
-
hqvBuf->pinnedOffset = wsbmBOOffset(hqvBuf->buf);
hqvBuf->deltaY = 0;
@@ -1049,6 +1049,7 @@ CreateSurface(ScrnInfoPtr pScrn, CARD32 FourCC, CARD16 Width,
memset(hqvBuf->virtual, 0xff, pitch*Height);
wsbmBOUnmap(hqvBuf->buf);
+ hqvBuf->virtual = NULL;
}
}
diff --git a/src/via_video.c b/src/via_video.c
index e83d33b..6df2726 100644
--- a/src/via_video.c
+++ b/src/via_video.c
@@ -1352,13 +1352,18 @@ viaPutImage(ScrnInfoPtr pScrn,
}
hqvBuf = &pVia->swov.SWDevice.hqvBuf[pVia->dwFrameNum & 1];
- virtual = wsbmBOMap(hqvBuf->buf, 1, WSBM_SYNCCPU_WRITE);
+ virtual = wsbmBOMap(hqvBuf->buf, WSBM_ACCESS_WRITE);
if (virtual == NULL) {
viaXvError(pScrn, pPriv, xve_mem);
return BadAlloc;
}
+ if (wsbmBOSyncForCpu(hqvBuf->buf, WSBM_SYNCCPU_WRITE)) {
+ wsbmBOUnmap(hqvBuf->buf);
+ viaXvError(pScrn, pPriv, xve_mem);
+ return BadAlloc;
+ }
/* Copy image data from system memory to video memory
* TODO: use DRM's DMA feature to accelerate data copy
@@ -1375,7 +1380,7 @@ viaPutImage(ScrnInfoPtr pScrn,
width, height,
dstPitch, id)) {
viaXvError(pScrn, pPriv, xve_dmablit);
- return BadAccess;
+ return BadAccess;
}
#endif
#endif
@@ -1386,7 +1391,7 @@ viaPutImage(ScrnInfoPtr pScrn,
nv12cp(virtual,
buf, dstPitch, width, height, 0);
} else {
- (*viaFastVidCpy)(hqvBuf->virtual,
+ (*viaFastVidCpy)(virtual,
buf, dstPitch, width, height, 0);
}
break;
@@ -1406,7 +1411,9 @@ viaPutImage(ScrnInfoPtr pScrn,
}
}
+ wsbmBOReleaseFromCpu(hqvBuf->buf, WSBM_SYNCCPU_WRITE);
wsbmBOUnmap(hqvBuf->buf);
+
/* If there is bandwidth issue, block the H/W overlay */
if (!pVia->OverlaySupported &&