summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-07-28 17:36:00 +0100
committerThomas White <taw@bitwiz.org.uk>2009-07-28 17:36:50 +0100
commit4fa134e23f682cdb57b01072ee07ee90342266b9 (patch)
tree05c4b92dd943ba42b278b2b26db8e5b21483945e
parent839e7e06a1e24c66233b77b50e454b286caadf93 (diff)
Initialisation no longer segfaults...
-rw-r--r--src/Makefile.am2
-rw-r--r--src/glamo-dri2.c1
-rw-r--r--src/glamo-dri2.h2
-rw-r--r--src/glamo-drm-cmdq.h2
-rw-r--r--src/glamo-kms-driver.c17
-rw-r--r--src/glamo-kms-exa.c67
6 files changed, 71 insertions, 20 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index e49ae6f..374be96 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,7 +25,7 @@
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ -pedantic -Wall -Werror -std=gnu99
glamo_drv_la_LTLIBRARIES = glamo_drv.la
-glamo_drv_la_LDFLAGS = -module -avoid-version
+glamo_drv_la_LDFLAGS = -module -avoid-version -ldrm -ldrm_glamo
glamo_drv_ladir = @moduledir@/drivers
glamo_drv_la_SOURCES = \
diff --git a/src/glamo-dri2.c b/src/glamo-dri2.c
index 2491f82..b500067 100644
--- a/src/glamo-dri2.c
+++ b/src/glamo-dri2.c
@@ -181,6 +181,5 @@ void driScreenInit(ScreenPtr pScreen)
void driCloseScreen(ScreenPtr pScreen)
{
- driUnlock(pScreen);
DRI2CloseScreen(pScreen);
}
diff --git a/src/glamo-dri2.h b/src/glamo-dri2.h
index 8ec99b9..5834410 100644
--- a/src/glamo-dri2.h
+++ b/src/glamo-dri2.h
@@ -24,5 +24,3 @@
extern void driScreenInit(ScreenPtr pScreen);
extern void driCloseScreen(ScreenPtr pScreen);
-extern void driLock(ScreenPtr pScreen);
-extern void driUnlock(ScreenPtr pScreen);
diff --git a/src/glamo-drm-cmdq.h b/src/glamo-drm-cmdq.h
index 11d1752..85df1c0 100644
--- a/src/glamo-drm-cmdq.h
+++ b/src/glamo-drm-cmdq.h
@@ -109,7 +109,7 @@ do { \
__packet0count = n; \
} while (0)
-#endif
+#endif /* CCE_DEBUG */
#define OUT_PAIR(v1, v2) \
do { \
diff --git a/src/glamo-kms-driver.c b/src/glamo-kms-driver.c
index bc4d933..ac19ead 100644
--- a/src/glamo-kms-driver.c
+++ b/src/glamo-kms-driver.c
@@ -311,6 +311,15 @@ static Bool GlamoKMSCreateScreenResources(ScreenPtr pScreen)
if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL))
FatalError("Couldn't adjust screen pixmap\n");
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Adding framebuffer....!\n");
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%i %i %i %i %i %i\n",
+ pGlamo->drm_fd, pScrn->virtualX, pScrn->virtualY,
+ pScrn->depth, pScrn->bitsPerPixel,
+ pScrn->displayWidth * pScrn->bitsPerPixel / 8);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "rootPixmap = %p\n", (void *)rootPixmap);
+
drmModeAddFB(pGlamo->drm_fd,
pScrn->virtualX,
pScrn->virtualY,
@@ -319,10 +328,14 @@ static Bool GlamoKMSCreateScreenResources(ScreenPtr pScreen)
pScrn->displayWidth * pScrn->bitsPerPixel / 8,
driGetPixmapHandle(rootPixmap, &flags), &pGlamo->fb_id);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Done\n");
+
GlamoKMSAdjustFrame(pScrn->scrnIndex,
pScrn->frameX0, pScrn->frameY0,
0);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Finished\n");
+
return ret;
}
@@ -431,8 +444,6 @@ Bool GlamoKMSEnterVT(int scrnIndex, int flags)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
GlamoPtr pGlamo = GlamoPTR(pScrn);
- driUnlock(pScrn->pScreen);
-
/* Only save state once per server generation since that's what most
* drivers do. Could change this to save state at each VT enter. */
if ( pGlamo->SaveGeneration != serverGeneration ) {
@@ -473,8 +484,6 @@ void GlamoKMSLeaveVT(int scrnIndex, int flags)
drmModeRmFB(pGlamo->drm_fd, pGlamo->fb_id);
- driLock(pScrn->pScreen);
-
pScrn->vtSema = FALSE;
}
diff --git a/src/glamo-kms-exa.c b/src/glamo-kms-exa.c
index f46a0b1..22c609e 100644
--- a/src/glamo-kms-exa.c
+++ b/src/glamo-kms-exa.c
@@ -58,6 +58,7 @@
#include <drm/glamo_drm.h>
#include <drm/glamo_bo.h>
+#include <drm/glamo_bo_gem.h>
#include <xf86drm.h>
@@ -150,6 +151,9 @@ unsigned int driGetPixmapHandle(PixmapPtr pPixmap, unsigned int *flags)
FatalError("NO PIXMAP PRIVATE\n");
return 0;
}
+ xf86Msg(X_INFO, "priv=%p\n", (void *)priv);
+ xf86Msg(X_INFO, "priv->bo=%p\n", (void *)priv->bo);
+ xf86Msg(X_INFO, "priv->bo->handle=%i\n", priv->bo->handle);
return priv->bo->handle;
}
@@ -159,22 +163,22 @@ Bool GlamoKMSExaPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
{
ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum];
GlamoPtr pGlamo = GlamoPTR(pScrn);
- CARD32 offset;
CARD16 op, pitch;
FbBits mask;
RING_LOCALS;
struct glamo_exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPix);
- if (pPix->drawable.bitsPerPixel != 16)
+ if (pPix->drawable.bitsPerPixel != 16) {
GLAMO_FALLBACK(("Only 16bpp is supported\n"));
+ }
mask = FbFullMask(16);
- if ((pm & mask) != mask)
+ if ((pm & mask) != mask) {
GLAMO_FALLBACK(("Can't do planemask 0x%08x\n",
- (unsigned int) pm));
+ (unsigned int)pm));
+ }
op = GLAMOSolidRop[alu] << 8;
- offset = exaGetPixmapOffset(pPix);
pitch = pPix->devKind;
BEGIN_CMDQ(16);
@@ -379,6 +383,8 @@ static void *GlamoKMSExaCreatePixmap(ScreenPtr screen, int size, int align)
0 /* flags */ );
if (!new_priv->bo) {
xfree(new_priv);
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Failed to create pixmap\n");
return NULL;
}
@@ -478,21 +484,54 @@ static Bool GlamoKMSExaModifyPixmapHeader(PixmapPtr pPix, int width, int height,
{
ScreenPtr screen = pPix->drawable.pScreen;
ScrnInfoPtr pScrn = xf86Screens[screen->myNum];
-// GlamoPtr pGlamo = GlamoPTR(pScrn);
- PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
+ GlamoPtr pGlamo = GlamoPTR(pScrn);
+ struct glamo_exa_pixmap_priv *priv;
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ModifyPixmapHeader. "
"%ix%ix%i %ibpp, %i\n",
width, height, depth,
bitsPerPixel, devKind);
+ if (depth <= 0) depth = pPix->drawable.depth;
+ if (bitsPerPixel <= 0) bitsPerPixel = pPix->drawable.bitsPerPixel;
+ if (width <= 0) width = pPix->drawable.width;
+ if (height <= 0) height = pPix->drawable.height;
+ if (width <= 0 || height <= 0 || depth <= 0) return FALSE;
+
miModifyPixmapHeader(pPix, width, height, depth,
bitsPerPixel, devKind, NULL);
- if ( pPix == screen_pixmap ) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Screen pixmap!");
+ priv = exaGetPixmapDriverPrivate(pPix);
+ if (!priv) {
+ /* This should never, ever, happen */
+ FatalError("NO PIXMAP PRIVATE\n");
+ return FALSE;
}
+ if ( priv->bo == NULL ) {
+
+ int size;
+
+ /* This pixmap has no associated buffer object.
+ * It's time to create one */
+ size = width * height * (depth/8);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Creating pixmap BO"
+ " (%i bytes)\n", size);
+ priv->bo = pGlamo->bufmgr->funcs->bo_open(pGlamo->bufmgr,
+ 0, /* handle */
+ size,
+ 2,
+ GLAMO_GEM_DOMAIN_VRAM,
+ 0 /* flags */ );
+
+ if ( priv->bo == NULL ) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Failed to create buffer object"
+ " in ModifyPixmapHeader.\n");
+ return FALSE;
+ }
+
+ }
return FALSE;
}
@@ -507,9 +546,9 @@ void GlamoKMSExaClose(ScrnInfoPtr pScrn)
void GlamoKMSExaInit(ScrnInfoPtr pScrn)
{
GlamoPtr pGlamo = GlamoPTR(pScrn);
-
Bool success = FALSE;
ExaDriverPtr exa;
+ MemBuf *buf;
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"EXA hardware acceleration initialising\n");
@@ -551,10 +590,16 @@ void GlamoKMSExaInit(ScrnInfoPtr pScrn)
// exa->MarkSync = GlamoKMSExaMarkSync;
exa->WaitMarker = GlamoKMSExaWaitMarker;
-
+ /* Prepare temporary buffers */
pGlamo->cmdq_objs = malloc(1024);
pGlamo->cmdq_obj_pos = malloc(1024);
pGlamo->cmdq_obj_used = 0;
+ pGlamo->ring_len = 4 * 1024;
+ buf = (MemBuf *)xcalloc(1, sizeof(MemBuf) + pGlamo->ring_len);
+ if (!buf) return;
+ buf->size = pGlamo->ring_len;
+ buf->used = 0;
+ pGlamo->cmd_queue = buf;
/* Tell EXA that we're going to take care of memory
* management ourselves. */