Merge commit 'origin/dri2'

This commit is contained in:
Keith Packard 2008-12-01 19:06:09 -08:00
commit f7540df184
9 changed files with 327 additions and 75 deletions

View File

@ -261,6 +261,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])

View File

@ -371,6 +371,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;
@ -575,8 +582,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;
@ -588,6 +594,7 @@ typedef struct _I830Rec {
I830ConfigPrivPtr pVisualConfigsPriv;
drm_handle_t buffer_map;
drm_handle_t ring_map;
char deviceName[64];
#endif
/* Broken-out options. */
@ -809,6 +816,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,

View File

@ -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, TRUE);
if (pI830->directRenderingEnabled) {
if (pI830->directRenderingType > DRI_NONE) {
struct drm_i915_irq_emit emit;
struct drm_i915_irq_wait wait;
int ret;
@ -308,6 +308,7 @@ I830AccelInit(ScreenPtr pScreen)
* i915 limits 3D textures to pitch of 16B - 8kB, in dwords.
* i915 limits 3D destination to ~4kB-aligned offset if tiled.
* i915 limits 3D destination to pitch of 16B - 8kB, in dwords, if un-tiled.
* i915 limits 3D destination to pitch 64B-aligned if used with depth.
* i915 limits 3D destination to pitch of 512B - 8kB, in tiles, if tiled.
* i915 limits 3D destination to POT aligned pitch if tiled.
* i915 limits 3D destination drawing rect to w,h of 2048,2048.
@ -327,12 +328,12 @@ I830AccelInit(ScreenPtr pScreen)
*/
if (IS_I965G(pI830)) {
pI830->accel_pixmap_offset_alignment = 4 * 2;
pI830->accel_pixmap_pitch_alignment = 16;
pI830->accel_pixmap_pitch_alignment = 64;
pI830->accel_max_x = 8192;
pI830->accel_max_y = 8192;
} else {
pI830->accel_pixmap_offset_alignment = 4;
pI830->accel_pixmap_pitch_alignment = 16;
pI830->accel_pixmap_pitch_alignment = 64;
pI830->accel_max_x = 2048;
pI830->accel_max_y = 2048;
}

View File

@ -127,7 +127,7 @@ intel_batch_init(ScrnInfoPtr pScrn)
intel_next_batch(pScrn);
if (!pI830->directRenderingEnabled) {
if (pI830->directRenderingType <= DRI_NONE) {
if (IS_I830(pI830) || IS_845G(pI830)) {
intel_bufmgr_fake_set_exec_callback(pI830->bufmgr,
intel_nondrm_exec_i830,

View File

@ -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->pipe;
@ -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.
@ -912,7 +912,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;

View File

@ -68,6 +68,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <sys/types.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include "xf86.h"
#include "xf86_OSproc.h"
@ -88,6 +90,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,
@ -964,7 +970,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;
}
@ -985,7 +991,7 @@ I830DRICloseScreen(ScreenPtr pScreen)
xfree(pI830->pVisualConfigs);
if (pI830->pVisualConfigsPriv)
xfree(pI830->pVisualConfigsPriv);
pI830->directRenderingEnabled = FALSE;
pI830->directRenderingType = DRI_NONE;
}
static Bool
@ -1574,6 +1580,9 @@ i830_update_sarea(ScrnInfoPtr pScrn, drmI830Sarea *sarea)
ScreenPtr pScreen = pScrn->pScreen;
I830Ptr pI830 = I830PTR(pScrn);
if (pI830->directRenderingType == DRI_DRI2)
return;
sarea->width = pScreen->width;
sarea->height = pScreen->height;
sarea->pitch = pScrn->displayWidth;
@ -1671,6 +1680,9 @@ i830_update_dri_mappings(ScrnInfoPtr pScrn, drmI830Sarea *sarea)
{
I830Ptr pI830 = I830PTR(pScrn);
if (pI830->directRenderingType == DRI_DRI2)
return TRUE;
if (!i830_do_addmap(pScrn, pI830->front_buffer, &sarea->front_handle,
&sarea->front_size, &sarea->front_offset)) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Disabling DRI.\n");
@ -1761,7 +1773,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)
@ -1787,7 +1799,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)
@ -1805,8 +1817,207 @@ 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;
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;
}
pDepthPixmap = NULL;
for (i = 0; i < count; i++) {
if (attachments[i] == DRI2BufferFrontLeft) {
if (pDraw->type == DRAWABLE_PIXMAP)
pPixmap = (PixmapPtr) pDraw;
else
pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
pPixmap->refcnt++;
} else if (attachments[i] == DRI2BufferStencil && pDepthPixmap) {
pPixmap = pDepthPixmap;
pPixmap->refcnt++;
} else {
pPixmap = (*pScreen->CreatePixmap)(pScreen,
pDraw->width,
pDraw->height,
pDraw->depth, 0);
}
if (attachments[i] == DRI2BufferDepth)
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 (dri_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 unsigned int
I830DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
DRI2BufferPtr pDestBuffer, DRI2BufferPtr pSrcBuffer)
{
I830DRI2BufferPrivatePtr private = pSrcBuffer->driverPrivate;
ScreenPtr pScreen = pDraw->pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
PixmapPtr pPixmap = private->pPixmap;
RegionPtr pCopyClip;
GCPtr pGC;
pGC = GetScratchGC(pDraw->depth, pScreen);
pCopyClip = REGION_CREATE(pScreen, NULL, 0);
REGION_COPY(pScreen, pCopyClip, pRegion);
(*pGC->funcs->ChangeClip) (pGC, CT_REGION, pCopyClip, 0);
ValidateGC(pDraw, pGC);
(*pGC->ops->CopyArea)(&pPixmap->drawable,
pDraw, pGC, 0, 0, pDraw->width, pDraw->height, 0, 0);
FreeScratchGC(pGC);
/* Emit a flush of the rendering cache, or on the 965 and beyond
* rendering results may not hit the framebuffer until significantly
* later.
*/
I830EmitFlush(pScrn);
pI830->need_mi_flush = FALSE;
/* 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, TRUE);
#if ALWAYS_SYNC
I830Sync(pScrn);
#endif
drmCommandNone(pI830->drmSubFD, DRM_I915_GEM_THROTTLE);
return 1;
}
Bool I830DRI2ScreenInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
DRI2InfoRec info;
char *p, *busId, buf[64];
int fd, i, cmp;
if (pI830->accel != ACCEL_UXA) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "DRI2 requires UXA\n");
return FALSE;
}
sprintf(buf, "pci:%04x:%02x:%02x.%d",
pI830->PciInfo->domain,
pI830->PciInfo->bus,
pI830->PciInfo->dev,
pI830->PciInfo->func);
info.fd = drmOpen("i915", buf);
if (info.fd < 0) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to open DRM device\n");
return FALSE;
}
/* The whole drmOpen thing is a fiasco and we need to find a way
* back to just using open(2). For now, however, lets just make
* things worse with even more ad hoc directory walking code to
* discover the device file name. */
p = pI830->deviceName;
for (i = 0; i < DRM_MAX_MINOR; i++) {
sprintf(p, DRM_DEV_NAME, DRM_DIR_NAME, i);
fd = open(p, O_RDWR);
if (fd < 0)
continue;
busId = drmGetBusid(fd);
close(fd);
if (busId == NULL)
continue;
cmp = strcmp(busId, buf);
drmFree(busId);
if (cmp == 0)
break;
}
if (i == DRM_MAX_MINOR) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"DRI2: failed to open drm device\n");
return FALSE;
}
info.driverName = IS_I965G(pI830) ? "i965" : "i915";
info.deviceName = p;
info.version = 1;
info.CreateBuffers = I830DRI2CreateBuffers;
info.DestroyBuffers = I830DRI2DestroyBuffers;
info.CopyRegion = I830DRI2CopyRegion;
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

View File

@ -1553,22 +1553,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 =
xf86ReturnOptValBool(pI830->Options, OPTION_LEGACY3D, TRUE);
}
@ -1627,8 +1628,8 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
char *bus_id;
char *s;
/* Default to EXA but allow override */
pI830->accel = ACCEL_EXA;
/* Default to UXA but allow override */
pI830->accel = ACCEL_UXA;
if ((s = (char *)xf86GetOptValString(pI830->Options, OPTION_ACCELMETHOD))) {
if (!xf86NameCmp(s, "EXA"))
@ -1636,7 +1637,7 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
else if (!xf86NameCmp(s, "UXA"))
pI830->accel = ACCEL_UXA;
else
pI830->accel = ACCEL_EXA;
pI830->accel = ACCEL_UXA;
}
bus_id = DRICreatePCIBusID(pI830->PciInfo);
@ -1654,7 +1655,7 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
pI830->drmSubFD = pI830->drmmode.fd;
xfree(bus_id);
pI830->directRenderingDisabled = FALSE;
pI830->directRenderingType = DRI_DRI2;
pI830->allocate_classic_textures = FALSE;
i830_init_bufmgr(pScrn);
@ -1693,7 +1694,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",
@ -1709,7 +1710,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;
@ -1717,7 +1718,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;
@ -1986,13 +1987,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;
@ -2591,7 +2600,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 */
@ -2743,7 +2752,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",
@ -2756,7 +2765,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",
@ -2860,14 +2869,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;
}
}
@ -2966,7 +2975,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;
}
}
@ -2987,8 +2996,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++) {
@ -3089,16 +3098,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 */
@ -3255,25 +3265,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
@ -3375,8 +3385,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
@ -3420,19 +3431,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");
@ -3517,7 +3532,8 @@ I830LeaveVT(int scrnIndex, int flags)
}
#ifdef XF86DRI
if (pI830->directRenderingOpen) {
if (pI830->directRenderingOpen &&
pI830->directRenderingType == DRI_XF86DRI) {
DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
if (!pI830->memory_manager) {
@ -3676,7 +3692,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.
*/
@ -3687,7 +3703,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;
}
@ -3806,7 +3822,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);
@ -3821,6 +3838,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);

View File

@ -904,10 +904,12 @@ i830_uxa_init (ScreenPtr pScreen)
i830->uxa_driver->composite = i830_composite;
i830->uxa_driver->done_composite = i830_done_composite;
} else {
#if 0
i830->uxa_driver->check_composite = i965_check_composite;
i830->uxa_driver->prepare_composite = i965_prepare_composite;
i830->uxa_driver->composite = i965_composite;
i830->uxa_driver->done_composite = i830_done_composite;
#endif
}
i830->uxa_driver->prepare_access = i830_uxa_prepare_access;

View File

@ -435,14 +435,14 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size)
has_gem = FALSE;
has_dri = FALSE;
if (pI830->directRenderingEnabled &&
if (pI830->directRenderingType == DRI_XF86DRI &&
xf86LoaderCheckSymbol ("DRIQueryVersion"))
{
DRIQueryVersion(&dri_major, &dri_minor, &dri_patch);
has_dri = TRUE;
}
if (pI830->directRenderingEnabled)
if (pI830->directRenderingType >= DRI_XF86DRI)
{
has_gem = FALSE;
gp.param = I915_PARAM_HAS_GEM;
@ -457,8 +457,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 && has_dri &&
(dri_major > 5 || (dri_major == 5 && dri_minor >= 4)))
if ((pI830->directRenderingType == DRI_XF86DRI && has_gem && has_dri &&
(dri_major > 5 || (dri_major == 5 && dri_minor >= 4))) ||
(pI830->directRenderingType == DRI_DRI2 && has_gem))
{
int mmsize;