summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-10-14 23:57:10 -0400
committerKristian Høgsberg <krh@redhat.com>2008-10-14 23:57:10 -0400
commit3dd7f0f9423bb891bc99cd3b77dc3d57e057a7ef (patch)
treeafd089e9653e172cf1a9e28a216d834d5b69b2b7
parent282f51c3f0e5bc2cedd2f60f458ca2662290d471 (diff)
Update to DRI2 changes.dri2
Implement DRI2CopyRegion and provide drm device filename to DRI2 module.
-rw-r--r--src/i830.h1
-rw-r--r--src/i830_accel.c2
-rw-r--r--src/i830_dri.c69
-rw-r--r--src/i830_driver.c8
4 files changed, 61 insertions, 19 deletions
diff --git a/src/i830.h b/src/i830.h
index 55db7728..823bfefe 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -593,6 +593,7 @@ typedef struct _I830Rec {
I830ConfigPrivPtr pVisualConfigsPriv;
drm_handle_t buffer_map;
drm_handle_t ring_map;
+ char deviceName[64];
#endif
/* Broken-out options. */
diff --git a/src/i830_accel.c b/src/i830_accel.c
index c935af63..52e22ba8 100644
--- a/src/i830_accel.c
+++ b/src/i830_accel.c
@@ -322,7 +322,7 @@ 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 {
diff --git a/src/i830_dri.c b/src/i830_dri.c
index da1588ca..12de9d45 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -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"
@@ -1850,13 +1852,13 @@ I830DRI2CreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
pDepthPixmap = NULL;
for (i = 0; i < count; i++) {
- if (attachments[i] == DRI2_BUFFER_FRONT_LEFT) {
+ if (attachments[i] == DRI2BufferFrontLeft) {
if (pDraw->type == DRAWABLE_PIXMAP)
pPixmap = (PixmapPtr) pDraw;
else
pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw);
pPixmap->refcnt++;
- } else if (attachments[i] == DRI2_BUFFER_STENCIL && pDepthPixmap) {
+ } else if (attachments[i] == DRI2BufferStencil && pDepthPixmap) {
pPixmap = pDepthPixmap;
pPixmap->refcnt++;
} else {
@@ -1866,7 +1868,7 @@ I830DRI2CreateBuffers(DrawablePtr pDraw, unsigned int *attachments, int count)
pDraw->depth, 0);
}
- if (attachments[i] == DRI2_BUFFER_DEPTH)
+ if (attachments[i] == DRI2BufferDepth)
pDepthPixmap = pPixmap;
buffers[i].attachment = attachments[i];
@@ -1907,20 +1909,24 @@ I830DRI2DestroyBuffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
}
static void
-I830DRI2SwapBuffers(DrawablePtr pDraw, DRI2BufferPtr pSrcBuffer,
- int x, int y, int width, int height)
+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, x, y, width, height, x, y);
+ 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
@@ -1944,26 +1950,61 @@ Bool I830DRI2ScreenInit(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I830Ptr pI830 = I830PTR(pScrn);
DRI2InfoRec info;
- char busId[64];
+ 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(busId, "PCI:%d:%d:%d",
- ((pI830->PciInfo->domain << 8) | pI830->PciInfo->bus),
- pI830->PciInfo->dev, pI830->PciInfo->func);
+ 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.fd = drmOpen(info.driverName, busId);
- if (info.fd < 0)
- return FALSE;
info.CreateBuffers = I830DRI2CreateBuffers;
info.DestroyBuffers = I830DRI2DestroyBuffers;
- info.SwapBuffers = I830DRI2SwapBuffers;
+ info.CopyRegion = I830DRI2CopyRegion;
pI830->drmSubFD = info.fd;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 46e33bfa..7bc10fd6 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1661,8 +1661,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"))
@@ -1670,7 +1670,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);
@@ -1688,7 +1688,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);