summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-08-08 15:36:35 -0400
committerKristian Høgsberg <krh@redhat.com>2008-08-29 14:31:02 -0400
commitfd6a9ca5b59a868260eb91272091ea6169091737 (patch)
tree32749adb38721a55db7165dc155a72962396a90d
parent6404ac178bf2c32a715a66e7fd6ab0184a05af36 (diff)
Add DRI2 support.
-rw-r--r--configure.ac1
-rw-r--r--src/i830.h15
-rw-r--r--src/i830_accel.c6
-rw-r--r--src/i830_batchbuffer.c2
-rw-r--r--src/i830_display.c10
-rw-r--r--src/i830_dri.c175
-rw-r--r--src/i830_driver.c122
-rw-r--r--src/i830_exa.c2
-rw-r--r--src/i830_memory.c8
9 files changed, 272 insertions, 69 deletions
diff --git a/configure.ac b/configure.ac
index e276f0e1..161005eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -245,6 +245,7 @@ if test "$XVMC" = yes; then
AC_SUBST([XVMCLIB_CFLAGS])
fi
+AC_DEFINE(DRI2, 1,[Enable DRI2 code])
AC_SUBST([DRI_CFLAGS])
AC_SUBST([XORG_CFLAGS])
diff --git a/src/i830.h b/src/i830.h
index f0efc4ed..29ed714d 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -374,6 +374,13 @@ typedef enum accel_method {
ACCEL_UXA
} accel_method_t;
+enum dri_type {
+ DRI_DISABLED,
+ DRI_NONE,
+ DRI_XF86DRI,
+ DRI_DRI2
+};
+
typedef struct _I830Rec {
unsigned char *MMIOBase;
unsigned char *GTTBase;
@@ -577,8 +584,7 @@ typedef struct _I830Rec {
/* 965 render acceleration state */
struct gen4_render_state *gen4_render_state;
- Bool directRenderingDisabled; /* DRI disabled in PreInit. */
- Bool directRenderingEnabled; /* DRI enabled this generation. */
+ enum dri_type directRenderingType; /* DRI enabled this generation. */
#ifdef XF86DRI
Bool directRenderingOpen;
@@ -807,6 +813,11 @@ extern Bool I830DRISetHWS(ScrnInfoPtr pScrn);
extern Bool I830DRIInstIrqHandler(ScrnInfoPtr pScrn);
#endif
+#ifdef DRI2
+Bool I830DRI2ScreenInit(ScreenPtr pScreen);
+void I830DRI2CloseScreen(ScreenPtr pScreen);
+#endif
+
extern Bool I830AccelInit(ScreenPtr pScreen);
extern void I830SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
int ydir, int rop,
diff --git a/src/i830_accel.c b/src/i830_accel.c
index 386e653f..4059121f 100644
--- a/src/i830_accel.c
+++ b/src/i830_accel.c
@@ -138,7 +138,7 @@ I830WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis)
i830_dump_error_state(pScrn);
ErrorF("space: %d wanted %d\n", ring->space, n);
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
DRICloseScreen(screenInfo.screens[pScrn->scrnIndex]);
}
@@ -183,7 +183,7 @@ I830Sync(ScrnInfoPtr pScrn)
#ifdef XF86DRI
/* VT switching tries to do this.
*/
- if (!pI830->LockHeld && pI830->directRenderingEnabled) {
+ if (!pI830->LockHeld && pI830->directRenderingType == DRI_XF86DRI) {
return;
}
#endif
@@ -194,7 +194,7 @@ I830Sync(ScrnInfoPtr pScrn)
intel_batch_flush(pScrn);
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType > DRI_NONE) {
struct drm_i915_irq_emit emit;
struct drm_i915_irq_wait wait;
int ret;
diff --git a/src/i830_batchbuffer.c b/src/i830_batchbuffer.c
index 07ea0825..055d7dfa 100644
--- a/src/i830_batchbuffer.c
+++ b/src/i830_batchbuffer.c
@@ -120,7 +120,7 @@ intel_batch_flush(ScrnInfoPtr pScrn)
} else {
dri_process_relocs(pI830->batch_bo);
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType > DRI_NONE) {
struct drm_i915_batchbuffer batch;
int ret;
diff --git a/src/i830_display.c b/src/i830_display.c
index cfd4e6fd..3257b797 100644
--- a/src/i830_display.c
+++ b/src/i830_display.c
@@ -422,7 +422,7 @@ i830PipeSetBase(xf86CrtcPtr crtc, int x, int y)
}
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
drmI830Sarea *sPriv = (drmI830Sarea *) DRIGetSAREAPrivate(pScrn->pScreen);
if (!sPriv)
@@ -745,7 +745,7 @@ i830_use_fb_compression(xf86CrtcPtr crtc)
return TRUE;
}
-#if defined(DRM_IOCTL_MODESET_CTL) && defined(XF86DRI)
+#if defined(DRM_IOCTL_MODESET_CTL) && (defined(XF86DRI) || defined(DRI2))
static void i830_modeset_ctl(xf86CrtcPtr crtc, int pre)
{
ScrnInfoPtr pScrn = crtc->scrn;
@@ -753,7 +753,7 @@ static void i830_modeset_ctl(xf86CrtcPtr crtc, int pre)
I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
struct drm_modeset_ctl modeset;
- if (!pI830-directRenderingEnabled)
+ if (pI830->directRenderingType <= DRI_NONE)
return;
modeset.crtc = intel_crtc->plane;
@@ -777,7 +777,7 @@ static void i830_modeset_ctl(xf86CrtcPtr crtc, int dpms_state)
{
return;
}
-#endif /* DRM_IOCTL_MODESET_CTL && XF86DRI */
+#endif /* DRM_IOCTL_MODESET_CTL && (XF86DRI || DRI2) */
/**
* Sets the power management mode of the pipe and plane.
@@ -902,7 +902,7 @@ i830_crtc_dpms(xf86CrtcPtr crtc, int mode)
intel_crtc->dpms_mode = mode;
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
drmI830Sarea *sPriv = (drmI830Sarea *) DRIGetSAREAPrivate(pScrn->pScreen);
Bool enabled = crtc->enabled && mode != DPMSModeOff;
diff --git a/src/i830_dri.c b/src/i830_dri.c
index ca3bc621..2b4a46f5 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -88,6 +88,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "dristruct.h"
+#ifdef DRI2
+#include "dri2.h"
+#endif
+
static Bool I830InitVisualConfigs(ScreenPtr pScreen);
static Bool I830CreateContext(ScreenPtr pScreen, VisualPtr visual,
drm_context_t hwContext, void *pVisualConfigPriv,
@@ -934,12 +938,14 @@ Bool
I830DRIResume(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
DPRINTF(PFX, "I830DRIResume\n");
I830ResumeDma(pScrn);
- I830DRIInstIrqHandler(pScrn);
+ if (!pI830->memory_manager)
+ I830DRIInstIrqHandler(pScrn);
return TRUE;
}
@@ -957,7 +963,7 @@ I830DRICloseScreen(ScreenPtr pScreen)
REGION_UNINIT(pScreen, &pI830->driRegion);
#endif
- if (pI830DRI->irq) {
+ if (!pI830->memory_manager && pI830DRI->irq) {
drmCtlUninstHandler(pI830->drmSubFD);
pI830DRI->irq = 0;
}
@@ -978,7 +984,7 @@ I830DRICloseScreen(ScreenPtr pScreen)
xfree(pI830->pVisualConfigs);
if (pI830->pVisualConfigsPriv)
xfree(pI830->pVisualConfigsPriv);
- pI830->directRenderingEnabled = FALSE;
+ pI830->directRenderingType = DRI_NONE;
}
static Bool
@@ -1756,7 +1762,7 @@ I830DRISetVBlankInterrupt (ScrnInfoPtr pScrn, Bool on)
if (!pI830->want_vblank_interrupts)
on = FALSE;
- if (pI830->directRenderingEnabled && pI830->drmMinor >= 5) {
+ if (pI830->directRenderingType == DRI_XF86DRI && pI830->drmMinor >= 5) {
if (on) {
if (xf86_config->num_crtc > 1 && xf86_config->crtc[1]->enabled)
if (pI830->drmMinor >= 6)
@@ -1782,7 +1788,7 @@ I830DRILock(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
- if (pI830->directRenderingEnabled && !pI830->LockHeld) {
+ if (pI830->directRenderingType == DRI_XF86DRI && !pI830->LockHeld) {
DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
pI830->LockHeld = 1;
if (!pI830->memory_manager)
@@ -1800,8 +1806,165 @@ I830DRIUnlock(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
- if (pI830->directRenderingEnabled && pI830->LockHeld) {
+ if (pI830->directRenderingType == DRI_XF86DRI && pI830->LockHeld) {
DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
pI830->LockHeld = 0;
}
}
+
+#ifdef DRI2
+
+typedef struct {
+ PixmapPtr pPixmap;
+} I830DRI2BufferPrivateRec, *I830DRI2BufferPrivatePtr;
+
+static DRI2BufferPtr
+I830DRI2CreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2BufferPtr buffers;
+ dri_bo *bo;
+ int i, depth, width, cpp;
+ I830DRI2BufferPrivatePtr privates;
+ PixmapPtr pPixmap, pDepthPixmap;
+
+ buffers = xcalloc(count, sizeof *buffers);
+ if (buffers == NULL)
+ return NULL;
+ privates = xcalloc(count, sizeof *privates);
+ if (privates == NULL) {
+ xfree(buffers);
+ return NULL;
+ }
+
+ /* The byte rowstride for 3D buffers must be a multiple of 64 bytes. */
+ cpp = pDraw->bitsPerPixel / 8;
+ width = ((pDraw->width * cpp + 63) & ~63) / cpp;
+
+ pDepthPixmap = NULL;
+ for (i = 0; i < count; i++) {
+ if (attachments[i] == DRI2_BUFFER_FRONT_LEFT) {
+ if (pDraw->type == DRAWABLE_PIXMAP)
+ pPixmap = (PixmapPtr) pDraw;
+ else
+ pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
+ pPixmap->refcnt++;
+ } else if (attachments[i] == DRI2_BUFFER_STENCIL && pDepthPixmap) {
+ pPixmap = pDepthPixmap;
+ pPixmap->refcnt++;
+ } else {
+ pPixmap = (*pScreen->CreatePixmap)(pScreen,
+ width,
+ pDraw->height,
+ pDraw->depth, 0);
+ }
+
+ if (attachments[i] == DRI2_BUFFER_DEPTH)
+ pDepthPixmap = pPixmap;
+
+ buffers[i].attachment = attachments[i];
+ buffers[i].pitch = pPixmap->devKind;
+ buffers[i].cpp = pPixmap->drawable.bitsPerPixel / 8;
+ buffers[i].driverPrivate = &privates[i];
+ buffers[i].flags = 0; /* not tiled */
+ privates[i].pPixmap = pPixmap;
+
+ bo = i830_get_pixmap_bo (pPixmap);
+ if (intel_bo_flink(bo, &buffers[i].name) != 0) {
+ /* failed to name buffer */
+ }
+
+ }
+
+ return buffers;
+}
+
+static void
+I830DRI2DestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ I830DRI2BufferPrivatePtr private;
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ private = buffers[i].driverPrivate;
+ (*pScreen->DestroyPixmap)(private->pPixmap);
+ }
+
+ if (buffers)
+ {
+ xfree(buffers[0].driverPrivate);
+ xfree(buffers);
+ }
+}
+
+static void
+I830DRI2SwapBuffers(DrawablePtr pDraw, DRI2BufferPtr pSrcBuffer,
+ int x, int y, int width, int height)
+{
+ I830DRI2BufferPrivatePtr private = pSrcBuffer->driverPrivate;
+ ScreenPtr pScreen = pDraw->pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+ PixmapPtr pPixmap = private->pPixmap;
+ GCPtr pGC;
+
+ pGC = GetScratchGC(pDraw->depth, pScreen);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->CopyArea)(&pPixmap->drawable,
+ pDraw, pGC, x, y, width, height, x, y);
+ FreeScratchGC(pGC);
+
+ /* We can't rely on getting into the block handler before the DRI
+ * client gets to run again so flush now. */
+ intel_batch_flush(pScrn);
+ I830EmitFlush(pScrn);
+ pI830->need_mi_flush = FALSE;
+#if ALWAYS_SYNC
+ I830Sync(pScrn);
+#endif
+ drmCommandNone(pI830->drmSubFD, DRM_I915_GEM_THROTTLE);
+}
+
+Bool I830DRI2ScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+ DRI2InfoRec info;
+ char busId[64];
+
+ if (pI830->accel != ACCEL_UXA) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "DRI2 requires UXA\n");
+ return FALSE;
+ }
+
+ sprintf(busId, "PCI:%d:%d:%d",
+ ((pI830->PciInfo->domain << 8) | pI830->PciInfo->bus),
+ pI830->PciInfo->dev, pI830->PciInfo->func);
+
+ info.driverName = IS_I965G(pI830) ? "i965" : "i915";
+ info.version = 1;
+ info.fd = drmOpen(info.driverName, busId);
+ if (info.fd < 0)
+ return FALSE;
+
+ info.CreateBuffers = I830DRI2CreateBuffers;
+ info.DestroyBuffers = I830DRI2DestroyBuffers;
+ info.SwapBuffers = I830DRI2SwapBuffers;
+
+ pI830->drmSubFD = info.fd;
+
+ return DRI2ScreenInit(pScreen, &info);
+}
+
+void I830DRI2CloseScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I830Ptr pI830 = I830PTR(pScrn);
+
+ DRI2CloseScreen(pScreen);
+ pI830->directRenderingType = DRI_NONE;
+}
+
+#endif
diff --git a/src/i830_driver.c b/src/i830_driver.c
index afce7188..04f26464 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1541,22 +1541,23 @@ I830AccelMethodInit(ScrnInfoPtr pScrn)
pI830->SWCursor = TRUE;
}
- pI830->directRenderingDisabled =
- !xf86ReturnOptValBool(pI830->Options, OPTION_DRI, TRUE);
+ pI830->directRenderingType = DRI_NONE;
+ if (!xf86ReturnOptValBool(pI830->Options, OPTION_DRI, TRUE))
+ pI830->directRenderingType = DRI_DISABLED;
#ifdef XF86DRI
- if (!pI830->directRenderingDisabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
if ((pI830->accel == ACCEL_NONE) || pI830->SWCursor) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it "
"needs HW cursor and 2D acceleration.\n");
- pI830->directRenderingDisabled = TRUE;
+ pI830->directRenderingType = DRI_DISABLED;
} else if (pScrn->depth != 16 && pScrn->depth != 24) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "DRI is disabled because it "
"runs only at depths 16 and 24.\n");
- pI830->directRenderingDisabled = TRUE;
+ pI830->directRenderingType = DRI_DISABLED;
}
- if (!pI830->directRenderingDisabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
pI830->allocate_classic_textures = TRUE;
from = X_PROBED;
@@ -1714,7 +1715,7 @@ I830XvInit(ScrnInfoPtr pScrn)
#endif
#ifdef INTEL_XVMC
pI830->XvMCEnabled = FALSE;
- from = (!pI830->directRenderingDisabled &&
+ from = (!pI830->directRenderingType != DRI_DISABLED &&
xf86GetOptValBool(pI830->Options, OPTION_XVMC,
&pI830->XvMCEnabled)) ? X_CONFIG : X_DEFAULT;
xf86DrvMsg(pScrn->scrnIndex, from, "Intel XvMC decoder %sabled\n",
@@ -1730,7 +1731,7 @@ I830DriOptsInit(ScrnInfoPtr pScrn)
MessageType from = X_PROBED;
pI830->allowPageFlip = FALSE;
- from = (!pI830->directRenderingDisabled &&
+ from = (!pI830->directRenderingType != DRI_DISABLED &&
xf86GetOptValBool(pI830->Options, OPTION_PAGEFLIP,
&pI830->allowPageFlip)) ? X_CONFIG : X_DEFAULT;
@@ -1738,7 +1739,7 @@ I830DriOptsInit(ScrnInfoPtr pScrn)
pI830->allowPageFlip ? "" : " not");
pI830->TripleBuffer = FALSE;
- from = (!pI830->directRenderingDisabled &&
+ from = (!pI830->directRenderingType != DRI_DISABLED &&
xf86GetOptValBool(pI830->Options, OPTION_TRIPLEBUFFER,
&pI830->TripleBuffer)) ? X_CONFIG : X_DEFAULT;
@@ -2007,13 +2008,21 @@ I830PreInit(ScrnInfoPtr pScrn, int flags)
#if defined(XF86DRI)
/* Load the dri module if requested. */
if (xf86ReturnOptValBool(pI830->Options, OPTION_DRI, FALSE) &&
- !pI830->directRenderingDisabled) {
+ !pI830->directRenderingType != DRI_DISABLED) {
if (xf86LoadSubModule(pScrn, "dri")) {
xf86LoaderReqSymLists(I810driSymbols, I810drmSymbols, NULL);
}
}
#endif
+#if defined(DRI2)
+ /* Load the dri2 module if requested. */
+ if (xf86ReturnOptValBool(pI830->Options, OPTION_DRI, FALSE) &&
+ pI830->directRenderingType != DRI_DISABLED) {
+ xf86LoadSubModule(pScrn, "dri2");
+ }
+#endif
+
pI830->preinit = FALSE;
return TRUE;
@@ -2606,7 +2615,7 @@ IntelEmitInvarientState(ScrnInfoPtr pScrn)
return;
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
drmI830Sarea *sarea = DRIGetSAREAPrivate(pScrn->pScreen);
/* Mark that the X Server was the last holder of the context */
@@ -2752,7 +2761,7 @@ i830_try_memory_allocation(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
Bool tiled = pI830->tiling;
- Bool dri = pI830->directRenderingEnabled;
+ Bool xf86dri = pI830->directRenderingType == DRI_XF86DRI;
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Attempting memory allocation with %stiled buffers.\n",
@@ -2765,7 +2774,7 @@ i830_try_memory_allocation(ScrnInfoPtr pScrn)
if (!i830_allocate_pwrctx(pScrn))
goto failed;
- if (dri && !i830_allocate_3d_memory(pScrn))
+ if (xf86dri && !i830_allocate_3d_memory(pScrn))
goto failed;
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%siled allocation successful.\n",
@@ -2869,14 +2878,14 @@ i830_memory_init(ScrnInfoPtr pScrn)
pI830->fb_compression = FALSE;
/* Try again, but leave DRI enabled */
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
if (i830_try_memory_allocation(pScrn))
return TRUE;
else {
i830_reset_allocations(pScrn);
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Couldn't allocate 3D memory, "
"disabling DRI.\n");
- pI830->directRenderingEnabled = FALSE;
+ pI830->directRenderingType = DRI_NONE;
}
}
@@ -3009,7 +3018,7 @@ I830AdjustMemory(ScreenPtr pScreen)
if (!IS_I965G(pI830) && pScrn->displayWidth > 2048) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Cannot support DRI with frame buffer width > 2048.\n");
- pI830->directRenderingDisabled = TRUE;
+ pI830->directRenderingType = DRI_DISABLED;
}
}
@@ -3030,8 +3039,8 @@ I830SwapPipes(ScrnInfoPtr pScrn)
* Also make sure the DRM can handle the swap.
*/
if (I830LVDSPresent(pScrn) && !IS_I965GM(pI830) && !IS_GM45(pI830) &&
- (!pI830->directRenderingEnabled ||
- (pI830->directRenderingEnabled && pI830->drmMinor >= 10))) {
+ (pI830->directRenderingType != DRI_XF86DRI ||
+ (pI830->directRenderingType == DRI_XF86DRI && pI830->drmMinor >= 10))) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "adjusting plane->pipe mappings "
"to allow for framebuffer compression\n");
for (c = 0; c < config->num_crtc; c++) {
@@ -3115,16 +3124,17 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
I830AdjustMemory(pScreen);
}
+#ifdef DRI2
+ if (pI830->directRenderingType == DRI_NONE && I830DRI2ScreenInit(pScreen))
+ pI830->directRenderingType = DRI_DRI2;
+#endif
+
#ifdef XF86DRI
/* If DRI hasn't been explicitly disabled, try to initialize it.
* It will be used by the memory allocator.
*/
- if (!pI830->directRenderingDisabled)
- pI830->directRenderingEnabled = I830DRIScreenInit(pScreen);
- else
- pI830->directRenderingEnabled = FALSE;
-#else
- pI830->directRenderingEnabled = FALSE;
+ if (pI830->directRenderingType == DRI_NONE && I830DRIScreenInit(pScreen))
+ pI830->directRenderingType = DRI_XF86DRI;
#endif
/* Enable tiling by default */
@@ -3273,25 +3283,25 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
* InitGLXVisuals call back.
*/
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
if (pI830->accel == ACCEL_NONE || pI830->SWCursor || (pI830->StolenOnly && I830IsPrimary(pScrn))) {
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "DRI is disabled because it "
"needs HW cursor, 2D accel and AGPGART.\n");
- pI830->directRenderingEnabled = FALSE;
+ pI830->directRenderingType = DRI_NONE;
}
}
- if (pI830->directRenderingEnabled)
- pI830->directRenderingEnabled = I830DRIDoMappings(pScreen);
+ if (pI830->directRenderingType == DRI_XF86DRI &&
+ !I830DRIDoMappings(pScreen))
+ pI830->directRenderingType = DRI_NONE;
/* If we failed for any reason, free DRI memory. */
- if (!pI830->directRenderingEnabled)
+ if (!pI830->directRenderingType != DRI_XF86DRI &&
+ pI830->back_buffer != NULL)
i830_free_3d_memory(pScrn);
if (!pI830->use_drm_mode)
I830SwapPipes(pScrn);
-#else
- pI830->directRenderingEnabled = FALSE;
#endif
#ifdef XF86DRI
@@ -3399,8 +3409,9 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Must be called before EnterVT, so we can acquire the DRI lock when
* binding our memory.
*/
- if (pI830->directRenderingEnabled)
- pI830->directRenderingEnabled = I830DRIFinishScreenInit(pScreen);
+ if (pI830->directRenderingType == DRI_XF86DRI &&
+ !I830DRIFinishScreenInit(pScreen))
+ pI830->directRenderingType = DRI_NONE;
#endif
/* Must force it before EnterVT, so we are in control of VT and
@@ -3444,19 +3455,23 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Setup 3D engine, needed for rotation too */
IntelEmitInvarientState(pScrn);
-#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+#if defined(XF86DRI) || defined(DRI2)
+ switch (pI830->directRenderingType) {
+ case DRI_XF86DRI:
pI830->directRenderingOpen = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Enabled\n");
- } else if (!pI830->use_drm_mode) {
- if (pI830->directRenderingDisabled)
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Disabled\n");
- else
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Failed\n");
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "failed to enable direct rendering, aborting\n");
- return FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "direct rendering: XF86DRI Enabled\n");
+ break;
+ case DRI_DRI2:
+ pI830->directRenderingOpen = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: DRI2 Enabled\n");
+ break;
+ case DRI_DISABLED:
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Disabled\n");
+ break;
+ case DRI_NONE:
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Failed\n");
+ break;
}
#else
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering: Not available\n");
@@ -3541,7 +3556,8 @@ I830LeaveVT(int scrnIndex, int flags)
}
#ifdef XF86DRI
- if (pI830->directRenderingOpen) {
+ if (pI830->directRenderingOpen &&
+ pI830->directRenderingType == DRI_XF86DRI) {
DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
I830DRISetVBlankInterrupt (pScrn, FALSE);
@@ -3698,7 +3714,7 @@ I830EnterVT(int scrnIndex, int flags)
}
#ifdef XF86DRI
- if (pI830->directRenderingEnabled) {
+ if (pI830->directRenderingType == DRI_XF86DRI) {
/* HW status is fixed, we need to set it up before any drm
* operation which accessing that page, like irq install, etc.
*/
@@ -3709,7 +3725,7 @@ I830EnterVT(int scrnIndex, int flags)
I830DRICloseScreen(pScrn->pScreen);
return FALSE;
}
- if (!I830DRIInstIrqHandler(pScrn)) {
+ if (!pI830->memory_manager && !I830DRIInstIrqHandler(pScrn)) {
I830DRICloseScreen(pScrn->pScreen);
return FALSE;
}
@@ -3830,7 +3846,8 @@ I830CloseScreen(int scrnIndex, ScreenPtr pScreen)
pI830->bufmgr = NULL;
#ifdef XF86DRI
- if (pI830->directRenderingOpen) {
+ if (pI830->directRenderingOpen &&
+ pI830->directRenderingType == DRI_XF86DRI) {
#ifdef DAMAGE
if (pI830->pDamage) {
PixmapPtr pPix = pScreen->GetScreenPixmap(pScreen);
@@ -3845,6 +3862,13 @@ I830CloseScreen(int scrnIndex, ScreenPtr pScreen)
}
#endif
+#ifdef DRI2
+ if (pI830->directRenderingOpen && pI830->directRenderingType == DRI_DRI2) {
+ pI830->directRenderingOpen = FALSE;
+ I830DRI2CloseScreen(pScreen);
+ }
+#endif
+
if (I830IsPrimary(pScrn)) {
xf86GARTCloseScreen(scrnIndex);
diff --git a/src/i830_exa.c b/src/i830_exa.c
index e73bc36a..4cfbdb90 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -903,6 +903,7 @@ i830_uxa_init (ScreenPtr pScreen)
i830->uxa_driver->copy = I830EXACopy;
i830->uxa_driver->done_copy = I830EXADoneCopy;
+#if 0
/* Composite */
if (!IS_I9XX(i830)) {
i830->uxa_driver->check_composite = i830_check_composite;
@@ -922,6 +923,7 @@ i830_uxa_init (ScreenPtr pScreen)
i830->uxa_driver->composite = i965_composite;
i830->uxa_driver->done_composite = i830_done_composite;
}
+#endif
i830->uxa_driver->prepare_access = i830_uxa_prepare_access;
i830->uxa_driver->finish_access = i830_uxa_finish_access;
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 443cc4e5..1e428d96 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -408,7 +408,8 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size)
pI830->memory_list = start;
#ifdef XF86DRI
- DRIQueryVersion(&dri_major, &dri_minor, &dri_patch);
+ if (pI830->directRenderingType == DRI_XF86DRI)
+ DRIQueryVersion(&dri_major, &dri_minor, &dri_patch);
has_gem = 0;
gp.param = I915_PARAM_HAS_GEM;
@@ -422,8 +423,9 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size)
* 5.4 or newer so we can rely on the lock being held after DRIScreenInit,
* rather than after DRIFinishScreenInit.
*/
- if (pI830->directRenderingEnabled && has_gem &&
- (dri_major > 5 || (dri_major == 5 && dri_minor >= 4)))
+ if ((pI830->directRenderingType == DRI_XF86DRI && has_gem &&
+ (dri_major > 5 || (dri_major == 5 && dri_minor >= 4))) ||
+ (pI830->directRenderingType == DRI_DRI2 && has_gem))
{
int mmsize;