diff options
author | Kristian Høgsberg <krh@redhat.com> | 2009-02-18 17:26:06 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@redhat.com> | 2009-02-18 17:26:06 -0500 |
commit | 872aadc7102bd5131e1582ede081e22672911ba2 (patch) | |
tree | ff05701c45f6246f3b1fd0126a56eea41e47f99c | |
parent | 527e8177cde3abbabbcdccee0dbc0dcc0068a1be (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.
-rw-r--r-- | src/i830_driver.c | 2 | ||||
-rw-r--r-- | src/i830_video.c | 98 | ||||
-rw-r--r-- | src/i830_video.h | 2 | ||||
-rw-r--r-- | src/i965_video.c | 11 |
4 files changed, 53 insertions, 60 deletions
diff --git a/src/i830_driver.c b/src/i830_driver.c index 571f4c27..adb9544f 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -3441,7 +3441,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) pI830->XvMCEnabled ? "en" : "dis"); #endif /* Init video */ - if (pI830->XvEnabled && !pI830->use_drm_mode) + if (pI830->XvEnabled) I830InitVideo(pScreen); #endif 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); diff --git a/src/i830_video.h b/src/i830_video.h index 3c2fa4c5..254ee32b 100644 --- a/src/i830_video.h +++ b/src/i830_video.h @@ -58,7 +58,7 @@ typedef struct { uint32_t videoStatus; Time offTime; Time freeTime; - i830_memory *buf; /** YUV data buffer */ + drm_intel_bo *buf; /** YUV data buffer */ Bool overlayOK; int oneLineMode; diff --git a/src/i965_video.c b/src/i965_video.c index 7cd20f36..72a55d6d 100644 --- a/src/i965_video.c +++ b/src/i965_video.c @@ -397,6 +397,7 @@ i965_create_dst_surface_state(ScrnInfoPtr scrn, static drm_intel_bo * i965_create_src_surface_state(ScrnInfoPtr scrn, + drm_intel_bo *src_bo, uint32_t src_offset, int src_width, int src_height, @@ -424,13 +425,18 @@ i965_create_src_surface_state(ScrnInfoPtr scrn, src_surf_state->ss0.mipmap_layout_mode = 0; src_surf_state->ss0.render_cache_read_mode = 0; - src_surf_state->ss1.base_addr = src_offset; src_surf_state->ss2.width = src_width - 1; src_surf_state->ss2.height = src_height - 1; src_surf_state->ss2.mip_count = 0; src_surf_state->ss2.render_target_rotation = 0; src_surf_state->ss3.pitch = src_pitch - 1; + src_surf_state->ss1.base_addr = + intel_emit_reloc(surface_bo, + offsetof(struct brw_surface_state, ss1), + src_bo, src_offset, + I915_GEM_DOMAIN_SAMPLER, 0); + drm_intel_bo_unmap(surface_bo); return surface_bo; } @@ -897,11 +903,11 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, video_pitch); #endif +#if 0 /* enable debug */ OUTREG (INST_PM, (1 << (16 + 4)) | (1 << 4)); -#if 0 ErrorF ("INST_PM 0x%08x\n", INREG(INST_PM)); #endif @@ -967,6 +973,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id, for (src_surf = 0; src_surf < n_src_surf; src_surf++) { drm_intel_bo *surf_bo = i965_create_src_surface_state(pScrn, + pPriv->buf, src_surf_base[src_surf], src_width[src_surf], src_height[src_surf], |