xf86-video-intel: Branch 'intel-kernelmode' - 2 commits - src/drmmode_display.c src/i830_exa.c src/i830_video.c src/i915_video.c
Dave Airlie
airlied at kemper.freedesktop.org
Thu Feb 28 20:30:13 PST 2008
src/drmmode_display.c | 9 ----
src/i830_exa.c | 11 +++++
src/i830_video.c | 109 ++++++++++++++++++++++++++++++++++++++------------
src/i915_video.c | 24 +++++++++--
4 files changed, 118 insertions(+), 35 deletions(-)
New commits:
commit c7878e6395adf06a95aa74708f08dd81fbcd0859
Author: Dave Airlie <airlied at redhat.com>
Date: Fri Feb 29 14:16:19 2008 +1000
initial textured video fixups ported from my original codebase
diff --git a/src/i830_exa.c b/src/i830_exa.c
index 56d900f..73338a1 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -547,7 +547,6 @@ static Bool I830EXAModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
return FALSE;
if (drmmode_is_rotate_pixmap(pScrn, pPixData, &driver_priv->bo)) {
- ErrorF("yes a rotate pixmap landed here %08x\n", driver_priv->bo);
/* this is a rotate pixmap */
dri_bo_unmap(driver_priv->bo);
dri_bo_reference(driver_priv->bo);
diff --git a/src/i830_video.c b/src/i830_video.c
index 8f0ac30..d009cf9 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -320,6 +320,50 @@ typedef struct {
#define I830OVERLAYREG(pI830) ((I830OverlayRegPtr)\
((pI830)->FbBase + \
(pI830)->overlay_regs->offset))
+
+static void *i830_video_alloc_buf(ScrnInfoPtr pScrn, int size)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ if (pI830->use_ttm_batch) {
+ return dri_bo_alloc(pI830->bufmgr, "xv surfaces",
+ size, GTT_PAGE_SIZE,
+ DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED | DRM_BO_FLAG_CACHED_MAPPED);
+
+ } else {
+ return i830_allocate_memory(pScrn, "xv surface buffer", size, 16, 0);
+ }
+}
+
+static void i830_video_free_buf(ScrnInfoPtr pScrn, void *buf)
+{
+ I830Ptr pI830 = I830PTR(pScrn);
+ if (pI830->use_ttm_batch) {
+ dri_bo_unreference((dri_bo *)buf);
+ } else {
+ i830_free_memory(pScrn, (i830_memory *)buf);
+ }
+}
+
+static void *i830_video_map_buf(I830Ptr pI830, I830PortPrivPtr pPriv)
+{
+ void *ret;
+
+ if (pI830->use_ttm_batch) {
+ dri_bo_map((dri_bo *)pPriv->buf, 1);
+ ret = ((dri_bo *)pPriv->buf)->virtual;
+ } else {
+ ret = pI830->FbBase;
+ }
+
+ return ret;
+}
+
+static void i830_video_unmap_buf(I830Ptr pI830, I830PortPrivPtr pPriv)
+{
+ if (pI830->use_ttm_batch)
+ dri_bo_unmap((dri_bo *)pPriv->buf);
+}
+
#if VIDEO_DEBUG
static void
CompareOverlay(I830Ptr pI830, CARD32 * overlay, int size)
@@ -1018,7 +1062,7 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
/* Sync before freeing the buffer, because the pages will be unbound.
*/
I830Sync(pScrn);
- i830_free_memory(pScrn, pPriv->buf);
+ i830_video_free_buf(pScrn, pPriv->buf);
pPriv->buf = NULL;
pPriv->videoStatus = 0;
} else {
@@ -1209,10 +1253,11 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
src = buf + (top * srcPitch) + (left << 1);
+ dst = i830_video_map_buf(pI830, pPriv);
if (pPriv->currentBuf == 0)
- dst = pI830->FbBase + pPriv->YBuf0offset;
+ dst += pPriv->YBuf0offset;
else
- dst = pI830->FbBase + pPriv->YBuf1offset;
+ dst += pPriv->YBuf1offset;
switch (pPriv->rotation) {
case RR_Rotate_0:
@@ -1285,6 +1330,7 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
}
break;
}
+ i830_video_unmap_buf(pI830, pPriv);
}
/* Copies planar data in *buf to UYVY-packed data in the screen atYBufXOffset.
@@ -1299,10 +1345,11 @@ I830CopyPlanarToPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
CARD8 *dst1, *srcy, *srcu, *srcv;
int y;
+ dst1 = i830_video_map_buf(pI830, pPriv);
if (pPriv->currentBuf == 0)
- dst1 = pI830->FbBase + pPriv->YBuf0offset;
+ dst1 += pPriv->YBuf0offset;
else
- dst1 = pI830->FbBase + pPriv->YBuf1offset;
+ dst1 += pPriv->YBuf1offset;
srcy = buf + (top * srcPitch) + left;
if (id == FOURCC_YV12) {
@@ -1344,6 +1391,7 @@ I830CopyPlanarToPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
srcv += srcPitch2;
}
}
+ i830_video_unmap_buf(pI830, pPriv);
}
static void
@@ -1371,10 +1419,11 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
ErrorF("src1 is %p, offset is %ld\n", src1,
(unsigned long)src1 - (unsigned long)buf);
#endif
+ dst1 = i830_video_map_buf(pI830, pPriv);
if (pPriv->currentBuf == 0)
- dst1 = pI830->FbBase + pPriv->YBuf0offset;
+ dst1 += pPriv->YBuf0offset;
else
- dst1 = pI830->FbBase + pPriv->YBuf1offset;
+ dst1 += pPriv->YBuf1offset;
switch (pPriv->rotation) {
case RR_Rotate_0:
@@ -1413,22 +1462,25 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
break;
}
+ i830_video_unmap_buf(pI830, pPriv);
+
/* Copy V data for YV12, or U data for I420 */
src2 = buf + (srcH * srcPitch) + ((top * srcPitch) >> 2) + (left >> 1);
#if 0
ErrorF("src2 is %p, offset is %ld\n", src2,
(unsigned long)src2 - (unsigned long)buf);
#endif
+ dst2 = i830_video_map_buf(pI830, pPriv);
if (pPriv->currentBuf == 0) {
if (id == FOURCC_I420)
- dst2 = pI830->FbBase + pPriv->UBuf0offset;
+ dst2 += pPriv->UBuf0offset;
else
- dst2 = pI830->FbBase + pPriv->VBuf0offset;
+ dst2 += pPriv->VBuf0offset;
} else {
if (id == FOURCC_I420)
- dst2 = pI830->FbBase + pPriv->UBuf1offset;
+ dst2 += pPriv->UBuf1offset;
else
- dst2 = pI830->FbBase + pPriv->VBuf1offset;
+ dst2 += pPriv->VBuf1offset;
}
switch (pPriv->rotation) {
@@ -1467,6 +1519,7 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
}
break;
}
+ i830_video_unmap_buf(pI830, pPriv);
/* Copy U data for YV12, or V data for I420 */
src3 = buf + (srcH * srcPitch) + ((srcH >> 1) * srcPitch2) +
@@ -1475,16 +1528,17 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
ErrorF("src3 is %p, offset is %ld\n", src3,
(unsigned long)src3 - (unsigned long)buf);
#endif
+ dst3 = i830_video_map_buf(pI830, pPriv);
if (pPriv->currentBuf == 0) {
if (id == FOURCC_I420)
- dst3 = pI830->FbBase + pPriv->VBuf0offset;
+ dst3 += pPriv->VBuf0offset;
else
- dst3 = pI830->FbBase + pPriv->UBuf0offset;
+ dst3 += pPriv->UBuf0offset;
} else {
if (id == FOURCC_I420)
- dst3 = pI830->FbBase + pPriv->VBuf1offset;
+ dst3 += pPriv->VBuf1offset;
else
- dst3 = pI830->FbBase + pPriv->UBuf1offset;
+ dst3 += pPriv->UBuf1offset;
}
switch (pPriv->rotation) {
@@ -1523,6 +1577,7 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
}
break;
}
+ i830_video_unmap_buf(pI830, pPriv);
}
typedef struct {
@@ -2341,13 +2396,12 @@ I830PutImage(ScrnInfoPtr 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);
+ i830_video_free_buf(pScrn, pPriv->buf);
pPriv->buf = NULL;
}
if (pPriv->buf == NULL) {
- pPriv->buf = i830_allocate_memory(pScrn, "xv buffer", alloc_size, 16,
- 0);
+ pPriv->buf = i830_video_alloc_buf(pScrn, alloc_size);
}
if (pPriv->buf == NULL)
@@ -2357,7 +2411,10 @@ I830PutImage(ScrnInfoPtr pScrn,
(pPriv->doubleBuffer ? size * 2 : size);
/* fixup pointers */
- pPriv->YBuf0offset = pPriv->buf->offset;
+ if (pI830->use_ttm_batch)
+ pPriv->YBuf0offset = 0;
+ else
+ pPriv->YBuf0offset = pPriv->buf->offset;
if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * width);
pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * width / 2);
@@ -2596,7 +2653,7 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
* unbound.
*/
I830Sync(pScrn);
- i830_free_memory(pScrn, pPriv->buf);
+ i830_video_free_buf(pScrn, pPriv->buf);
pPriv->buf = NULL;
pPriv->videoStatus = 0;
}
@@ -2654,7 +2711,7 @@ I830AllocateSurface(ScrnInfoPtr pScrn,
fbpitch = pI830->cpp * pScrn->displayWidth;
size = pitch * h;
- pPriv->buf = i830_allocate_memory(pScrn, "xv surface buffer", size, 16, 0);
+ pPriv->buf = i830_video_alloc_buf(pScrn, size);
if (pPriv->buf == NULL) {
xfree(surface->pitches);
xfree(surface->offsets);
@@ -2670,10 +2727,14 @@ I830AllocateSurface(ScrnInfoPtr pScrn,
surface->pScrn = pScrn;
surface->id = id;
surface->pitches[0] = pitch;
- surface->offsets[0] = pPriv->buf->offset;
+ if (pI830->use_ttm_batch)
+ surface->offsets[0] = 0;//pPriv->buf->offset;
+ else
+ surface->offsets[0] = pPriv->buf->offset;
surface->devPrivate.ptr = (pointer) pPriv;
- memset(pI830->FbBase + surface->offsets[0], 0, size);
+ if (!pI830->use_ttm_batch)
+ memset(pI830->FbBase + surface->offsets[0], 0, size);
return Success;
}
@@ -2709,7 +2770,7 @@ I830FreeSurface(XF86SurfacePtr surface)
I830StopSurface(surface);
/* Sync before freeing the buffer, because the pages will be unbound. */
I830Sync(pScrn);
- i830_free_memory(surface->pScrn, pPriv->buf);
+ i830_video_free_buf(pScrn, pPriv->buf);
pPriv->buf = NULL;
xfree(surface->pitches);
xfree(surface->offsets);
diff --git a/src/i915_video.c b/src/i915_video.c
index 6b20ad2..2006f00 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -148,7 +148,11 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(_3DSTATE_MAP_STATE | 3);
OUT_BATCH(0x00000001); /* texture map #1 */
- OUT_BATCH(pPriv->YBuf0offset);
+ if (pI830->use_ttm_batch) {
+ OUT_RELOC((dri_bo *)pPriv->buf, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, pPriv->YBuf0offset);
+ } else {
+ OUT_BATCH(pPriv->YBuf0offset);
+ }
ms3 = MAPSURF_422 | MS3_USE_FENCE_REGS;
switch (id) {
case FOURCC_YUY2:
@@ -245,21 +249,33 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
OUT_BATCH(_3DSTATE_MAP_STATE | 9);
OUT_BATCH(0x00000007);
- OUT_BATCH(pPriv->YBuf0offset);
+ if (pI830->use_ttm_batch) {
+ OUT_RELOC((dri_bo *)pPriv->buf, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, pPriv->YBuf0offset);
+ } else {
+ OUT_BATCH(pPriv->YBuf0offset);
+ }
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width - 1) << MS3_WIDTH_SHIFT;
OUT_BATCH(ms3);
OUT_BATCH(((video_pitch * 2 / 4) - 1) << MS4_PITCH_SHIFT);
- OUT_BATCH(pPriv->UBuf0offset);
+ if (pI830->use_ttm_batch) {
+ OUT_RELOC((dri_bo *)pPriv->buf, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, pPriv->UBuf0offset);
+ } else {
+ OUT_BATCH(pPriv->UBuf0offset);
+ }
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width / 2 - 1) << MS3_WIDTH_SHIFT;
OUT_BATCH(ms3);
OUT_BATCH(((video_pitch / 4) - 1) << MS4_PITCH_SHIFT);
- OUT_BATCH(pPriv->VBuf0offset);
+ if (pI830->use_ttm_batch) {
+ OUT_RELOC((dri_bo *)pPriv->buf, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ, pPriv->VBuf0offset);
+ } else {
+ OUT_BATCH(pPriv->VBuf0offset);
+ }
ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
ms3 |= (width / 2 - 1) << MS3_WIDTH_SHIFT;
commit a64375383634844a186d493b5b47de8401f5c754
Author: Dave Airlie <airlied at redhat.com>
Date: Fri Feb 29 14:15:07 2008 +1000
modesetting: fix rotation + new API to save handing bo ptrs around.
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index a053870..34cf2e0 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -263,7 +263,7 @@ drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
dri_bo_map(drmmode_crtc->rotate_bo, 1);
ret = drmModeAddFB(drmmode->fd, width, height, crtc->scrn->depth,
- crtc->scrn->depth, rotate_pitch, dri_bo_get_kernel_bo_ptr(drmmode_crtc->rotate_bo), &drmmode_crtc->rotate_fb_id);
+ crtc->scrn->depth, rotate_pitch, dri_bo_get_handle(drmmode_crtc->rotate_bo), &drmmode_crtc->rotate_fb_id);
if (ret) {
ErrorF("failed to add rotate fb\n");
}
@@ -347,7 +347,6 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
{
xf86CrtcPtr crtc;
drmmode_crtc_private_ptr drmmode_crtc;
- int i;
int cursor_size = 64 * 64 * 4;
uint32_t mask;
int ret;
@@ -497,13 +496,9 @@ const char *output_names[] = { "None",
static void
drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
{
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR (pScrn);
xf86OutputPtr output;
drmModeOutputPtr koutput;
drmmode_output_private_ptr drmmode_output;
- int i, c;
- int possible_crtcs = 0;
- int possible_clones = 0;
char name[32];
koutput = drmModeGetOutput(drmmode->fd, drmmode->mode_res->outputs[num]);
@@ -587,7 +582,7 @@ void drmmode_set_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int width, int heigh
int ret;
ret = drmModeAddFB(drmmode->fd, width, height, pScrn->depth,
- pScrn->depth, pitch, bo, &drmmode->fb_id);
+ pScrn->depth, pitch, bo->handle, &drmmode->fb_id);
if (ret) {
ErrorF("Failed to add fb\n");
diff --git a/src/i830_exa.c b/src/i830_exa.c
index daf47e9..56d900f 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -543,6 +543,18 @@ static Bool I830EXAModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
driver_priv = exaGetPixmapDriverPrivate(pPixmap);
+ if (!driver_priv)
+ return FALSE;
+
+ if (drmmode_is_rotate_pixmap(pScrn, pPixData, &driver_priv->bo)) {
+ ErrorF("yes a rotate pixmap landed here %08x\n", driver_priv->bo);
+ /* this is a rotate pixmap */
+ dri_bo_unmap(driver_priv->bo);
+ dri_bo_reference(driver_priv->bo);
+ miModifyPixmapHeader(pPixmap, width, height, depth,
+ bitsPerPixel, devKind, NULL);
+ }
+
if (pPixData == pI830->FbBase + pScrn->fbOffset) {
/* this is the front buffer pixmap so set it up as such..*/
driver_priv->flags |= I830_EXA_PIXMAP_IS_FRONTBUFFER;
More information about the xorg-commit
mailing list