summaryrefslogtreecommitdiff
path: root/src/i830_video.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2009-02-18 17:26:06 -0500
committerKristian Høgsberg <krh@redhat.com>2009-02-18 17:26:06 -0500
commit872aadc7102bd5131e1582ede081e22672911ba2 (patch)
treeff05701c45f6246f3b1fd0126a56eea41e47f99c /src/i830_video.c
parent527e8177cde3abbabbcdccee0dbc0dcc0068a1be (diff)
Make Xv used a buffer object instead of i830_memory.
We still pin the buffer object in case of overlay, but for textured video we're now no longer using i830_memory for Xv anymore.
Diffstat (limited to 'src/i830_video.c')
-rw-r--r--src/i830_video.c98
1 files changed, 42 insertions, 56 deletions
diff --git a/src/i830_video.c b/src/i830_video.c
index 8a3718d2..be2d28e3 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -620,7 +620,7 @@ I830InitVideo(ScreenPtr pScreen)
/* Set up overlay video if we can do it at this depth. */
if (!OVERLAY_NOEXIST(pI830) && pScrn->bitsPerPixel != 8 &&
- pI830->overlay_regs != NULL)
+ !pI830->use_drm_mode && pI830->overlay_regs != NULL)
{
overlayAdaptor = I830SetupImageVideoOverlay(pScreen);
if (overlayAdaptor != NULL) {
@@ -1073,10 +1073,9 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
if (pI830->entityPrivate)
pI830->entityPrivate->XvInUse = -1;
}
- /* Sync before freeing the buffer, because the pages will be unbound.
- */
- I830Sync(pScrn);
- i830_free_memory(pScrn, pPriv->buf);
+ if (!pPriv->textured)
+ drm_intel_bo_unpin(pPriv->buf);
+ drm_intel_bo_unreference(pPriv->buf);
pPriv->buf = NULL;
pPriv->videoStatus = 0;
} else {
@@ -1267,7 +1266,6 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
int srcPitch,
int dstPitch, int top, int left, int h, int w)
{
- I830Ptr pI830 = I830PTR(pScrn);
unsigned char *src, *dst;
int i,j;
unsigned char *s;
@@ -1280,10 +1278,11 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
src = buf + (top * srcPitch) + (left << 1);
+ drm_intel_bo_map(pPriv->buf, TRUE);
if (pPriv->currentBuf == 0)
- dst = pI830->FbBase + pPriv->YBuf0offset;
+ dst = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
else
- dst = pI830->FbBase + pPriv->YBuf1offset;
+ dst = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
switch (pPriv->rotation) {
case RR_Rotate_0:
@@ -1356,6 +1355,7 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
}
break;
}
+ drm_intel_bo_unmap(pPriv->buf);
}
static void
@@ -1364,7 +1364,6 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
int srcPitch2, int dstPitch, int srcH, int top, int left,
int h, int w, int id)
{
- I830Ptr pI830 = I830PTR(pScrn);
int i, j = 0;
unsigned char *src1, *src2, *src3, *dst1, *dst2, *dst3;
unsigned char *s;
@@ -1383,10 +1382,11 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
ErrorF("src1 is %p, offset is %ld\n", src1,
(unsigned long)src1 - (unsigned long)buf);
#endif
+ drm_intel_bo_map(pPriv->buf, TRUE);
if (pPriv->currentBuf == 0)
- dst1 = pI830->FbBase + pPriv->YBuf0offset;
+ dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf0offset;
else
- dst1 = pI830->FbBase + pPriv->YBuf1offset;
+ dst1 = (unsigned char *) pPriv->buf->virtual + pPriv->YBuf1offset;
switch (pPriv->rotation) {
case RR_Rotate_0:
@@ -1436,14 +1436,14 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
#endif
if (pPriv->currentBuf == 0) {
if (id == FOURCC_I420)
- dst2 = pI830->FbBase + pPriv->UBuf0offset;
+ dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf0offset;
else
- dst2 = pI830->FbBase + pPriv->VBuf0offset;
+ dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf0offset;
} else {
if (id == FOURCC_I420)
- dst2 = pI830->FbBase + pPriv->UBuf1offset;
+ dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf1offset;
else
- dst2 = pI830->FbBase + pPriv->VBuf1offset;
+ dst2 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf1offset;
}
switch (pPriv->rotation) {
@@ -1495,14 +1495,14 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
#endif
if (pPriv->currentBuf == 0) {
if (id == FOURCC_I420)
- dst3 = pI830->FbBase + pPriv->VBuf0offset;
+ dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf0offset;
else
- dst3 = pI830->FbBase + pPriv->UBuf0offset;
+ dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf0offset;
} else {
if (id == FOURCC_I420)
- dst3 = pI830->FbBase + pPriv->VBuf1offset;
+ dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->VBuf1offset;
else
- dst3 = pI830->FbBase + pPriv->UBuf1offset;
+ dst3 = (unsigned char *) pPriv->buf->virtual + pPriv->UBuf1offset;
}
switch (pPriv->rotation) {
@@ -1544,6 +1544,7 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
}
break;
}
+ drm_intel_bo_unmap(pPriv->buf);
}
typedef struct {
@@ -2374,29 +2375,27 @@ I830PutImage(ScrnInfoPtr pScrn,
if (pPriv->doubleBuffer)
alloc_size *= 2;
- if (pPriv->buf) {
- /* Wait for any previous acceleration to the buffer to have completed.
- * When we start using BOs for rendering, we won't have to worry
- * because mapping or freeing will take care of it automatically.
- */
- I830Sync(pScrn);
- }
-
/* Free the current buffer if we're going to have to reallocate */
if (pPriv->buf && pPriv->buf->size < alloc_size) {
- i830_free_memory(pScrn, pPriv->buf);
+ if (!pPriv->textured)
+ drm_intel_bo_unpin(pPriv->buf);
+ drm_intel_bo_unreference(pPriv->buf);
pPriv->buf = NULL;
}
if (pPriv->buf == NULL) {
- pPriv->buf = i830_allocate_memory(pScrn, "xv buffer",
- alloc_size, 0, 16,
- 0, TILE_NONE);
+ pPriv->buf = drm_intel_bo_alloc(pI830->bufmgr,
+ "xv buffer", alloc_size, 4096);
+ if (pPriv->buf == NULL)
+ return BadAlloc;
+ if (!pPriv->textured && drm_intel_bo_pin(pPriv->buf, 4096) != 0) {
+ drm_intel_bo_unreference(pPriv->buf);
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to pin xv buffer\n");
+ return BadAlloc;
+ }
}
- if (pPriv->buf == NULL)
- return BadAlloc;
-
/* fixup pointers */
#ifdef INTEL_XVMC
if (id == FOURCC_XVMC && IS_I915(pI830)) {
@@ -2406,7 +2405,11 @@ I830PutImage(ScrnInfoPtr pScrn,
destId = FOURCC_YV12;
} else {
#endif
- pPriv->YBuf0offset = pPriv->buf->offset;
+ if (!pPriv->textured)
+ pPriv->YBuf0offset = pPriv->buf->offset;
+ else
+ pPriv->YBuf0offset = 0;
+
if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * width);
pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * width / 2);
@@ -2663,11 +2666,9 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
}
} else { /* FREE_TIMER */
if (pPriv->freeTime < now) {
- /* Sync before freeing the buffer, because the pages will be
- * unbound.
- */
- I830Sync(pScrn);
- i830_free_memory(pScrn, pPriv->buf);
+ if (!pPriv->textured)
+ drm_intel_bo_unpin(pPriv->buf);
+ drm_intel_bo_unreference(pPriv->buf);
pPriv->buf = NULL;
pPriv->videoStatus = 0;
}
@@ -2680,7 +2681,6 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
***************************************************************************/
typedef struct {
- i830_memory *buf;
Bool isOn;
} OffscreenPrivRec, *OffscreenPrivPtr;
@@ -2725,14 +2725,6 @@ I830AllocateSurface(ScrnInfoPtr pScrn,
fbpitch = pI830->cpp * pScrn->displayWidth;
size = pitch * h;
- pPriv->buf = i830_allocate_memory(pScrn, "xv surface buffer", size, 0, 16, 0, TILE_NONE);
- if (pPriv->buf == NULL) {
- xfree(surface->pitches);
- xfree(surface->offsets);
- xfree(pPriv);
- return BadAlloc;
- }
-
surface->width = w;
surface->height = h;
@@ -2741,11 +2733,9 @@ I830AllocateSurface(ScrnInfoPtr pScrn,
surface->pScrn = pScrn;
surface->id = id;
surface->pitches[0] = pitch;
- surface->offsets[0] = pPriv->buf->offset;
+ surface->offsets[0] = 0;
surface->devPrivate.ptr = (pointer) pPriv;
- memset(pI830->FbBase + surface->offsets[0], 0, size);
-
return Success;
}
@@ -2778,10 +2768,6 @@ I830FreeSurface(XF86SurfacePtr surface)
OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr;
I830StopSurface(surface);
- /* Sync before freeing the buffer, because the pages will be unbound. */
- I830Sync(pScrn);
- i830_free_memory(surface->pScrn, pPriv->buf);
- pPriv->buf = NULL;
xfree(surface->pitches);
xfree(surface->offsets);
xfree(surface->devPrivate.ptr);