summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am7
-rw-r--r--src/glamo-draw.c227
-rw-r--r--src/glamo-log.h2
-rw-r--r--src/glamo-video.c3
-rw-r--r--src/glamo.c28
-rw-r--r--src/glamo.h203
6 files changed, 249 insertions, 221 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index f46602c..5cb0ea2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,4 +29,9 @@ glamo_drv_la_LDFLAGS = -module -avoid-version
glamo_drv_ladir = @moduledir@/drivers
glamo_drv_la_SOURCES = \
- glamo.c
+ glamo.c \
+ glamo-cmdq.c \
+ glamo-funcs.c \
+ glamo-draw.c \
+ glamo-stub.c
+
diff --git a/src/glamo-draw.c b/src/glamo-draw.c
index e1b6805..62e85e6 100644
--- a/src/glamo-draw.c
+++ b/src/glamo-draw.c
@@ -1,8 +1,8 @@
/*
- * Copyright © 2007 OpenMoko, Inc.
+ * Copyright 2007 OpenMoko, Inc.
*
* This driver is based on Xati,
- * Copyright © 2003 Eric Anholt
+ * Copyright 2003 Eric Anholt
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -31,7 +31,6 @@
#include "glamo-regs.h"
#include "glamo-cmdq.h"
#include "glamo-draw.h"
-#include "kaa.h"
static const CARD8 GLAMOSolidRop[16] = {
/* GXclear */ 0x00, /* 0 */
@@ -168,11 +167,7 @@ MarkForWait(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
GLAMOScreenInfo(pScreenPriv);
- if (glamos->use_exa) {
- exaMarkSync(pScreen);
- } else {
- kaaMarkSync(pScreen);
- }
+ exaMarkSync(pScreen);
}
static void
@@ -180,11 +175,7 @@ WaitSync(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
GLAMOScreenInfo(pScreenPriv);
- if (glamos->use_exa) {
- exaWaitSync(pScreen);
- } else {
- kaaWaitSync(pScreen);
- }
+ exaWaitSync(pScreen);
}
void
@@ -247,7 +238,6 @@ GLAMOPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
END_CMDQ();
*/
- kaaMarkSync(glamos->screen->pScreen);
GLAMO_LOG("leave\n");
return TRUE;
@@ -283,7 +273,6 @@ static void
GLAMODoneSolid(void)
{
GLAMOScreenInfo *glamos = accel_glamos;
- kaaWaitSync(glamos->screen->pScreen);
if (glamos->cmd_queue_cache)
GLAMOFlushCMDQCache(glamos, 1);
}
@@ -325,7 +314,6 @@ GLAMOPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst,
glamos->srcPixmap = pSrc;
glamos->dstPixmap = pDst;
- kaaMarkSync(pDst->drawable.pScreen);
GLAMO_LOG("leave\n");
return TRUE;
@@ -374,11 +362,8 @@ GLAMODoneCopy(void)
{
GLAMOScreenInfo *glamos = accel_glamos;
GLAMO_LOG("enter\n");
- kaaWaitSync(glamos->screen->pScreen);
- kaaMarkSync(glamos->screen->pScreen);
if (glamos->cmd_queue_cache)
GLAMOFlushCMDQCache(glamos, 1);
- kaaWaitSync(glamos->screen->pScreen);
GLAMO_LOG("leave\n");
}
@@ -422,10 +407,8 @@ GLAMOBlockHandler(pointer blockData, OSTimePtr timeout, pointer readmask)
* make sure that the cmd queue cache
* has been flushed.
*/
- if (glamos->use_exa)
- exaWaitSync(pScreen);
- else
- kaaWaitSync(pScreen);
+ exaWaitSync(pScreen);
+
if (glamos->cmd_queue_cache)
GLAMOFlushCMDQCache(glamos, 1);
}
@@ -436,117 +419,53 @@ GLAMOWakeupHandler(pointer blockData, int result, pointer readmask)
}
Bool
-GLAMODrawKaaInit(ScreenPtr pScreen)
+GLAMODrawExaInit(ScreenPtr pScreen, ScrnInfoPtr pScrn)
{
- KdScreenPriv(pScreen);
- GLAMOScreenInfo(pScreenPriv);
- KdScreenInfo *screen = pScreenPriv->screen;
- int offscreen_memory_size = 0;
-
- offscreen_memory_size =
- screen->memory_size - screen->off_screen_base;
-
- LogMessage(X_INFO,
- "vram size:%d, "
- "onscreen vram size:%d, "
- "offscreen vram size:%d\n",
- screen->memory_size,
- screen->off_screen_base,
- offscreen_memory_size);
-
- GLAMO_LOG("enter\n");
-
- RegisterBlockAndWakeupHandlers(GLAMOBlockHandler, GLAMOWakeupHandler,
- pScreen);
-
- memset(&glamos->kaa, 0, sizeof(KaaScreenInfoRec));
- glamos->kaa.waitMarker = GLAMOWaitMarker;
- glamos->kaa.PrepareSolid = GLAMOPrepareSolid;
- glamos->kaa.Solid = GLAMOSolid;
- glamos->kaa.DoneSolid = GLAMODoneSolid;
- glamos->kaa.PrepareCopy = GLAMOPrepareCopy;
- glamos->kaa.Copy = GLAMOCopy;
- glamos->kaa.DoneCopy = GLAMODoneCopy;
- glamos->kaa.UploadToScreen = GLAMOUploadToScreen;
-
- if (offscreen_memory_size > 0) {
- glamos->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
- }
- glamos->kaa.offsetAlign = 16;
- glamos->kaa.pitchAlign = 16;
-
- if (!kaaDrawInit(pScreen, &glamos->kaa)) {
- GLAMO_LOG_ERROR("failed to init kaa\n");
- return FALSE;
- }
+ GlamoPtr pGlamo = GlamoPTR(pScrn)
- GLAMO_LOG("leave\n");
- return TRUE;
-}
-
-/**
- * exaDDXDriverInit is required by the top-level EXA module, and is used by
- * the xorg DDX to hook in its EnableDisableFB wrapper. We don't need it, since
- * we won't be enabling/disabling the FB.
- */
-#ifndef GetGLAMOExaPriv
-#define GetGLAMOExaPriv(pScreen) \
-(GLAMOScreenInfo*)pScreen->devPrivates[glamoExaScreenPrivateIndex].ptr
-#endif
-void
-exaDDXDriverInit(ScreenPtr pScreen)
-{
-}
-
-static int glamoExaScreenPrivateIndex;
-
-Bool
-GLAMODrawExaInit(ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- GLAMOScreenInfo(pScreenPriv);
- KdScreenInfo *screen = pScreenPriv->screen;
int offscreen_memory_size = 0;
- char *use_exa = NULL;
Bool success = FALSE;
+ ExaDriverPtr exa;
GLAMO_LOG("enter\n");
- memset(&glamos->exa, 0, sizeof(ExaDriverRec));
- glamos->exa.memoryBase = screen->memory_base;
- glamos->exa.memorySize = screen->memory_size;
- glamos->exa.offScreenBase = screen->off_screen_base;
+ exa = pGlamo->exa = exaDriverAlloc();
+ if(!exa) return FALSE;
+
+ exa->memoryBase = pGlamo->memory_base;
+ exa->memorySize = pGlamo->memory_size;
+ exa->offScreenBase = pGlamo->off_screen_base;
- glamos->exa.exa_major = 2;
- glamos->exa.exa_minor = 0;
+ exa->exa_major = 2;
+ exa->exa_minor = 0;
- glamos->exa.PrepareSolid = GLAMOExaPrepareSolid;
- glamos->exa.Solid = GLAMOExaSolid;
- glamos->exa.DoneSolid = GLAMOExaDoneSolid;
+ exa->PrepareSolid = GLAMOExaPrepareSolid;
+ exa->Solid = GLAMOExaSolid;
+ exa->DoneSolid = GLAMOExaDoneSolid;
- glamos->exa.PrepareCopy = GLAMOExaPrepareCopy;
- glamos->exa.Copy = GLAMOExaCopy;
- glamos->exa.DoneCopy = GLAMOExaDoneCopy;
+ exa->PrepareCopy = GLAMOExaPrepareCopy;
+ exa->Copy = GLAMOExaCopy;
+ exa->DoneCopy = GLAMOExaDoneCopy;
- glamos->exa.CheckComposite = GLAMOExaCheckComposite;
- glamos->exa.PrepareComposite = GLAMOExaPrepareComposite;
- glamos->exa.Composite = GLAMOExaComposite;
- glamos->exa.DoneComposite = GLAMOExaDoneComposite;
+ exa->CheckComposite = GLAMOExaCheckComposite;
+ exa->PrepareComposite = GLAMOExaPrepareComposite;
+ exa->Composite = GLAMOExaComposite;
+ exa->DoneComposite = GLAMOExaDoneComposite;
- glamos->exa.DownloadFromScreen = GLAMOExaDownloadFromScreen;
- glamos->exa.UploadToScreen = GLAMOExaUploadToScreen;
+ exa->DownloadFromScreen = GLAMOExaDownloadFromScreen;
+ exa->UploadToScreen = GLAMOExaUploadToScreen;
/*glamos->exa.MarkSync = GLAMOExaMarkSync;*/
- glamos->exa.WaitMarker = GLAMOExaWaitMarker;
+ exa->WaitMarker = GLAMOExaWaitMarker;
- glamos->exa.pixmapOffsetAlign = 1;
- glamos->exa.pixmapPitchAlign = 1;
+ exa->pixmapOffsetAlign = 1;
+ exa->pixmapPitchAlign = 1;
- glamos->exa.maxX = 640;
- glamos->exa.maxY = 640;
+ exa->maxX = 640;
+ exa->maxY = 640;
- glamos->exa.flags = EXA_OFFSCREEN_PIXMAPS;
+ exa->flags = EXA_OFFSCREEN_PIXMAPS;
RegisterBlockAndWakeupHandlers(GLAMOBlockHandler,
GLAMOWakeupHandler,
@@ -554,7 +473,7 @@ GLAMODrawExaInit(ScreenPtr pScreen)
glamoExaScreenPrivateIndex = AllocateScreenPrivateIndex() ;
pScreen->devPrivates[glamoExaScreenPrivateIndex].ptr = glamos;
- success = exaDriverInit(pScreen, &glamos->exa);
+ success = exaDriverInit(pScreen, exa);
if (success) {
ErrorF("Initialized EXA acceleration\n");
} else {
@@ -565,80 +484,6 @@ GLAMODrawExaInit(ScreenPtr pScreen)
return success;
}
-Bool
-GLAMODrawInit(ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- GLAMOScreenInfo(pScreenPriv);
- KdScreenInfo *screen = pScreenPriv->screen;
- int offscreen_memory_size = 0;
- char *use_exa = NULL;
-
- LogMessage(X_INFO, "Screen: %d/%d depth/bpp\n",
- pScreenPriv->screen->fb[0].depth,
- pScreenPriv->screen->fb[0].bitsPerPixel);
-
- use_exa = getenv("USE_EXA");
- if (use_exa && !strcmp(use_exa, "yes")) {
- glamos->use_exa = TRUE;
- return GLAMODrawExaInit(pScreen);
- } else {
- glamos->use_exa = FALSE;
- return GLAMODrawKaaInit(pScreen);
- }
-}
-
-#if 0
-static void
-GLAMOScratchSave(ScreenPtr pScreen, KdOffscreenArea *area)
-{
- KdScreenPriv(pScreen);
- GLAMOScreenInfo(pScreenPriv);
-
- glamos->scratch_area = NULL;
-}
-#endif
-
-void
-GLAMODrawEnable(ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- GLAMOScreenInfo(pScreenPriv);
-
- GLAMO_LOG("enter\n");
- GLAMOCMDQCacheSetup(pScreen);
- GLAMODrawSetup(pScreen);
- GLAMOEngineWait(pScreen, GLAMO_ENGINE_ALL);
- GLAMO_LOG("leave\n");
-
-
-}
-
-
-void
-GLAMODrawDisable(ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- GLAMOScreenInfo(pScreenPriv);
- if (!glamos->use_exa) {
- kaaWaitSync(pScreen);
- }
- GLAMOCMQCacheTeardown(pScreen);
-}
-
-void
-GLAMODrawFini(ScreenPtr pScreen)
-{
- KdScreenPriv(pScreen);
- GLAMOScreenInfo(pScreenPriv);
- RemoveBlockAndWakeupHandlers(GLAMOBlockHandler, GLAMOWakeupHandler,
- pScreen);
-
- if (!glamos->use_exa) {
- kaaDrawFini(pScreen);
- }
-}
-
/***************************************
* <glamo exa entry point definitions>
***************************************/
diff --git a/src/glamo-log.h b/src/glamo-log.h
index abd284b..70bbf1d 100644
--- a/src/glamo-log.h
+++ b/src/glamo-log.h
@@ -28,7 +28,7 @@
#define _GLAMO_LOG_H_
#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
+#include <config.h>
#endif
#include <assert.h>
diff --git a/src/glamo-video.c b/src/glamo-video.c
index c2f7cd2..c11e1ce 100644
--- a/src/glamo-video.c
+++ b/src/glamo-video.c
@@ -24,7 +24,7 @@
*/
#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
+#include <config.h>
#endif
@@ -35,7 +35,6 @@
#include "glamo-draw.h"
#include "glamo-regs.h"
#include "glamo-log.h"
-#include "kaa.h"
#include <X11/extensions/Xv.h>
#include "fourcc.h"
diff --git a/src/glamo.c b/src/glamo.c
index 7848096..6bc4c15 100644
--- a/src/glamo.c
+++ b/src/glamo.c
@@ -23,9 +23,6 @@
/* for visuals */
#include "fb.h"
-#ifdef USE_AFB
-#include "afb.h"
-#endif
#include "xf86Resources.h"
#include "xf86RAC.h"
@@ -38,6 +35,8 @@
#include <pciaccess.h>
#endif
+#include "glamo.h"
+
static Bool debug = 0;
#define TRACE_ENTER(str) \
@@ -236,29 +235,6 @@ GlamoSetup(pointer module, pointer opts, int *errmaj, int *errmin)
#endif /* XFree86LOADER */
-/* -------------------------------------------------------------------- */
-/* our private data, and two functions to allocate/free this */
-
-typedef struct {
- unsigned char* fbstart;
- unsigned char* fbmem;
- int fboff;
- int lineLength;
- int rotate;
- Bool shadowFB;
- void *shadow;
- CloseScreenProcPtr CloseScreen;
- CreateScreenResourcesProcPtr CreateScreenResources;
- void (*PointerMoved)(int index, int x, int y);
- EntityInfoPtr pEnt;
- /* DGA info */
- DGAModePtr pDGAMode;
- int nDGAMode;
- OptionInfoPtr Options;
-} GlamoRec, *GlamoPtr;
-
-#define GlamoPTR(p) ((GlamoPtr)((p)->driverPrivate))
-
static Bool
GlamoGetRec(ScrnInfoPtr pScrn)
{
diff --git a/src/glamo.h b/src/glamo.h
new file mode 100644
index 0000000..f18f222
--- /dev/null
+++ b/src/glamo.h
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2007 OpenMoko, Inc.
+ *
+ * This driver is based on Xati,
+ * Copyright 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ *
+ * Edited by:
+ * Dodji SEKETELI <dodji@openedhand.com>
+ */
+
+#ifndef _GLAMO_H_
+#define _GLAMO_H_
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "exa.h"
+
+#define GLAMO_REG_BASE(c) ((c)->attr.address[0])
+#define GLAMO_REG_SIZE(c) (0x2400)
+
+#ifdef __powerpc__
+
+static __inline__ void
+MMIO_OUT16(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwbrx %1,%2,%3\n\t"
+ "eieio"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ CARD32
+MMIO_IN16(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+#else
+
+#define MMIO_OUT16(mmio, a, v) (*(VOL16 *)((mmio) + (a)) = (v))
+#define MMIO_IN16(mmio, a) (*(VOL16 *)((mmio) + (a)))
+
+#endif
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+typedef struct _MemBuf {
+ int size;
+ int used;
+ void *address;
+} MemBuf;
+
+typedef struct {
+ unsigned char* fbstart;
+ unsigned char* fbmem;
+ int fboff;
+ int lineLength;
+ int rotate;
+ Bool shadowFB;
+ void *shadow;
+ CloseScreenProcPtr CloseScreen;
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ void (*PointerMoved)(int index, int x, int y);
+ EntityInfoPtr pEnt;
+ /* DGA info */
+ DGAModePtr pDGAMode;
+ int nDGAMode;
+ OptionInfoPtr Options;
+} GlamoRec, *GlamoPtr;
+
+#define GlamoPTR(p) ((GlamoPtr)((p)->driverPrivate))
+
+typedef struct _GLAMOScreenInfo {
+ PixmapPtr srcPixmap;
+ PixmapPtr dstPixmap;
+ CARD32 src_offset;
+ CARD32 dst_offset;
+ CARD32 src_pitch;
+ CARD32 dst_pitch;
+ CARD32 settings;
+ CARD32 foreground;
+
+ GLAMOCardInfo *glamoc;
+ KdScreenInfo *screen;
+
+ int scratch_offset;
+ int scratch_next;
+ KdOffscreenArea *scratch_area;
+
+ KdVideoAdaptorPtr pAdaptor;
+ int num_texture_ports;
+
+ KdOffscreenArea *cmd_queue; /* mmapped on-device cmd queue. */
+ ExaOffscreenArea *exa_cmd_queue;
+ CARD16 *ring_addr; /* Beginning of ring buffer. */
+ int ring_write; /* Index of write ptr in ring. */
+ int ring_read; /* Index of read ptr in ring. */
+ int ring_len;
+ /*
+ * cmd queue cache in system memory
+ * It is to be flushed to cmd_queue_space
+ * "at once", when we are happy with it.
+ */
+ MemBuf *cmd_queue_cache;
+ int cmd_queue_cache_start;
+} GLAMOScreenInfo;
+
+typedef union { float f; CARD32 i; } fi_type;
+
+/* Surely there's a better way to go about this */
+static inline CARD32
+GLAMOFloatAsInt(float val)
+{
+ fi_type fi;
+
+ fi.f = val;
+ return fi.i;
+}
+
+#define GET_FLOAT_BITS(x) GLAMOFloatAsInt(x)
+
+static inline void
+MMIOSetBitMask(char *mmio, CARD32 reg, CARD16 mask, CARD16 val)
+{
+ CARD16 tmp;
+
+ val &= mask;
+
+ tmp = MMIO_IN16(mmio, reg);
+ tmp &= ~mask;
+ tmp |= val;
+
+ MMIO_OUT16(mmio, reg, tmp);
+}
+
+/* glamo.c */
+Bool
+GLAMOMapReg(KdCardInfo *card, GLAMOCardInfo *glamoc);
+
+void
+GLAMOUnmapReg(KdCardInfo *card, GLAMOCardInfo *glamoc);
+
+void
+GLAMODumpRegs(GLAMOScreenInfo *glamos,
+ CARD16 from,
+ CARD16 to);
+
+/* glamo_draw.c */
+void
+GLAMODrawSetup(ScreenPtr pScreen);
+
+Bool
+GLAMODrawInit(ScreenPtr pScreen);
+
+void
+GLAMODrawEnable(ScreenPtr pScreen);
+
+void
+GLAMODrawDisable(ScreenPtr pScreen);
+
+void
+GLAMODrawFini(ScreenPtr pScreen);
+
+void
+GLAMORecolorCursor(ScreenPtr pScreen, int ndef, xColorItem *pdef);
+
+int
+GLAMOLog2(int val);
+
+extern KdCardFuncs GLAMOFuncs;
+
+#endif /* _GLAMO_H_ */