From ef499f51909762fa5a52820d8e05249add43ea9a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 3 May 2009 14:37:31 +0200 Subject: Code cleanup: * Delete unused files * Move engine code to it's own file * Remove some proxy functions --- src/Makefile.am | 5 +- src/glamo-cmdq.c | 250 ++----------------------------------------------------- src/glamo-cmdq.h | 50 +++-------- src/glamo-draw.c | 7 +- src/glamo-stub.c | 88 -------------------- src/glamo.h | 4 +- 6 files changed, 30 insertions(+), 374 deletions(-) delete mode 100644 src/glamo-stub.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 7bfdc12..d229347 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,8 +32,7 @@ glamo_drv_la_SOURCES = \ glamo-driver.c \ glamo.h \ glamo-cmdq.c \ - glamo-funcs.c \ glamo-draw.c \ glamo-display.c \ - glamo-output.c - + glamo-output.c \ + glamo-engine.c diff --git a/src/glamo-cmdq.c b/src/glamo-cmdq.c index 0c082c5..347ead3 100644 --- a/src/glamo-cmdq.c +++ b/src/glamo-cmdq.c @@ -31,7 +31,7 @@ #include "glamo.h" #include "glamo-regs.h" #include "glamo-cmdq.h" -#include "glamo-draw.h" +#include "glamo-engine.h" static void GLAMOCMDQResetCP(GlamoPtr pGlamo); @@ -66,235 +66,9 @@ GLAMODebugFifo(GlamoPtr pGlamo) #endif void -GLAMOEngineReset(GlamoPtr pGlamo, enum GLAMOEngine engine) +GLAMODispatchCMDQ(GlamoPtr pGlamo) { - CARD32 reg; - CARD16 mask; - volatile char *mmio = pGlamo->reg_base; - - if (!mmio) - return; - - switch (engine) { - case GLAMO_ENGINE_CMDQ: - reg = GLAMO_REG_CLOCK_2D; - mask = GLAMO_CLOCK_2D_CMDQ_RESET; - break; - case GLAMO_ENGINE_ISP: - reg = GLAMO_REG_CLOCK_ISP; - mask = GLAMO_CLOCK_ISP2_RESET; - break; - case GLAMO_ENGINE_2D: - reg = GLAMO_REG_CLOCK_2D; - mask = GLAMO_CLOCK_2D_RESET; - break; - default: - return; - break; - } - MMIOSetBitMask(mmio, reg, mask, 0xffff); - sleep(1); - MMIOSetBitMask(mmio, reg, mask, 0); - sleep(1); -} - -void -GLAMOEngineDisable(GlamoPtr pGlamo, enum GLAMOEngine engine) -{ - volatile char *mmio = pGlamo->reg_base; - - if (!mmio) - return; - - switch (engine) { - case GLAMO_ENGINE_CMDQ: - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_2D, - GLAMO_CLOCK_2D_EN_M6CLK, - 0); - MMIOSetBitMask(mmio, GLAMO_REG_HOSTBUS(2), - GLAMO_HOSTBUS2_MMIO_EN_CMDQ, - 0); - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_GEN5_1, - GLAMO_CLOCK_GEN51_EN_DIV_MCLK, - 0); - break; - case GLAMO_ENGINE_ISP: - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_ISP, - GLAMO_CLOCK_ISP_EN_M2CLK | - GLAMO_CLOCK_ISP_EN_I1CLK, - 0); - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_GEN5_2, - GLAMO_CLOCK_GEN52_EN_DIV_ICLK, - 0); - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_GEN5_1, - GLAMO_CLOCK_GEN51_EN_DIV_JCLK, - 0); - MMIOSetBitMask(mmio, GLAMO_REG_HOSTBUS(2), - GLAMO_HOSTBUS2_MMIO_EN_ISP, - 0); - break; - case GLAMO_ENGINE_2D: - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_2D, - GLAMO_CLOCK_2D_EN_M7CLK | - GLAMO_CLOCK_2D_EN_GCLK | - GLAMO_CLOCK_2D_DG_M7CLK | - GLAMO_CLOCK_2D_DG_GCLK, - 0); - MMIOSetBitMask(mmio, GLAMO_REG_HOSTBUS(2), - GLAMO_HOSTBUS2_MMIO_EN_2D, - 0); - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_GEN5_1, - GLAMO_CLOCK_GEN51_EN_DIV_GCLK, - 0); - break; - default: - break; - } -} - -void -GLAMOEngineEnable(GlamoPtr pGlamo, enum GLAMOEngine engine) -{ - volatile char *mmio = pGlamo->reg_base; - - if (!mmio) - return; - - switch (engine) { - case GLAMO_ENGINE_CMDQ: - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_2D, - GLAMO_CLOCK_2D_EN_M6CLK, - 0xffff); - MMIOSetBitMask(mmio, GLAMO_REG_HOSTBUS(2), - GLAMO_HOSTBUS2_MMIO_EN_CMDQ, - 0xffff); - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_GEN5_1, - GLAMO_CLOCK_GEN51_EN_DIV_MCLK, - 0xffff); - break; - case GLAMO_ENGINE_ISP: - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_ISP, - GLAMO_CLOCK_ISP_EN_M2CLK | - GLAMO_CLOCK_ISP_EN_I1CLK, - 0xffff); - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_GEN5_2, - GLAMO_CLOCK_GEN52_EN_DIV_ICLK, - 0xffff); - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_GEN5_1, - GLAMO_CLOCK_GEN51_EN_DIV_JCLK, - 0xffff); - MMIOSetBitMask(mmio, GLAMO_REG_HOSTBUS(2), - GLAMO_HOSTBUS2_MMIO_EN_ISP, - 0xffff); - break; - case GLAMO_ENGINE_2D: - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_2D, - GLAMO_CLOCK_2D_EN_M7CLK | - GLAMO_CLOCK_2D_EN_GCLK | - GLAMO_CLOCK_2D_DG_M7CLK | - GLAMO_CLOCK_2D_DG_GCLK, - 0xffff); - MMIOSetBitMask(mmio, GLAMO_REG_HOSTBUS(2), - GLAMO_HOSTBUS2_MMIO_EN_2D, - 0xffff); - MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_GEN5_1, - GLAMO_CLOCK_GEN51_EN_DIV_GCLK, - 0xffff); - break; - default: - break; - } -} - -int -GLAMOEngineBusy(GlamoPtr pGlamo, enum GLAMOEngine engine) -{ - volatile char *mmio = pGlamo->reg_base; - CARD16 status, mask, val; - - if (!mmio) - return FALSE; - - if (pGlamo->cmd_queue_cache != NULL) - GLAMOFlushCMDQCache(pGlamo, 0); - - switch (engine) - { - case GLAMO_ENGINE_CMDQ: - mask = 0x3; - val = mask; - break; - case GLAMO_ENGINE_ISP: - mask = 0x3 | (1 << 8); - val = 0x3; - break; - case GLAMO_ENGINE_2D: - mask = 0x3 | (1 << 4); - val = 0x3; - break; - case GLAMO_ENGINE_ALL: - default: - mask = 1 << 2; - val = mask; - break; - } - - status = MMIO_IN16(mmio, GLAMO_REG_CMDQ_STATUS); - - return !((status & mask) == val); -} - -static void -GLAMOEngineWaitReal(GlamoPtr pGlamo, - enum GLAMOEngine engine, - Bool do_flush) -{ - volatile char *mmio = pGlamo->reg_base; - CARD16 status, mask, val; - - if (!mmio) - return; - - if (pGlamo->cmd_queue_cache != NULL && do_flush) - GLAMOFlushCMDQCache(pGlamo, 0); - - switch (engine) - { - case GLAMO_ENGINE_CMDQ: - mask = 0x3; - val = mask; - break; - case GLAMO_ENGINE_ISP: - mask = 0x3 | (1 << 8); - val = 0x3; - break; - case GLAMO_ENGINE_2D: - mask = 0x3 | (1 << 4); - val = 0x3; - break; - case GLAMO_ENGINE_ALL: - default: - mask = 1 << 2; - val = mask; - break; - } - - do { - status = MMIO_IN16(mmio, GLAMO_REG_CMDQ_STATUS); - } while ((status & mask) != val); -} - -void -GLAMOEngineWait(GlamoPtr pGlamo, - enum GLAMOEngine engine) -{ - GLAMOEngineWaitReal(pGlamo, engine, TRUE); -} - -static void -GLAMODispatchCMDQCache(GlamoPtr pGlamo) -{ - MemBuf *buf = pGlamo->cmd_queue_cache; + MemBuf *buf = pGlamo->cmd_queue; volatile char *mmio = pGlamo->reg_base; char *addr; size_t count, ring_count; @@ -349,7 +123,7 @@ GLAMODispatchCMDQCache(GlamoPtr pGlamo) } else { memcpy(pGlamo->ring_addr + ring_write, addr, count); } - GLAMOEngineWaitReal(pGlamo, GLAMO_ENGINE_CMDQ, FALSE); + GLAMOEngineWait(pGlamo, GLAMO_ENGINE_CMDQ); MMIOSetBitMask(mmio, GLAMO_REG_CLOCK_2D, GLAMO_CLOCK_2D_EN_M6CLK, 0); @@ -365,12 +139,6 @@ GLAMODispatchCMDQCache(GlamoPtr pGlamo) buf->used = 0; } -void -GLAMOFlushCMDQCache(GlamoPtr pGlamo, Bool discard) -{ - GLAMODispatchCMDQCache(pGlamo); -} - static void GLAMOCMDQResetCP(GlamoPtr pGlamo) { @@ -395,7 +163,7 @@ GLAMOCMDQResetCP(GlamoPtr pGlamo) 1 << 12 | 5 << 8 | 8 << 4); - GLAMOEngineWaitReal(pGlamo, GLAMO_ENGINE_ALL, FALSE); + GLAMOEngineWait(pGlamo, GLAMO_ENGINE_ALL); } size_t @@ -418,7 +186,7 @@ GLAMOCMDQInit(ScrnInfoPtr pScrn, size_t mem_start, size_t mem_size) buf->size = pGlamo->ring_len; buf->used = 0; - pGlamo->cmd_queue_cache = buf; + pGlamo->cmd_queue = buf; return pGlamo->ring_len; } @@ -447,9 +215,9 @@ GLAMOCMDQFini(ScrnInfoPtr pScrn) { GLAMOCMDQDisable(pScrn); - if (pGlamo->cmd_queue_cache) { - xfree(pGlamo->cmd_queue_cache); - pGlamo->cmd_queue_cache = NULL; + if (pGlamo->cmd_queue) { + xfree(pGlamo->cmd_queue); + pGlamo->cmd_queue = NULL; } } diff --git a/src/glamo-cmdq.h b/src/glamo-cmdq.h index b6d9070..bce4819 100644 --- a/src/glamo-cmdq.h +++ b/src/glamo-cmdq.h @@ -33,16 +33,16 @@ #define RING_LOCALS CARD16 *__head; int __count #define BEGIN_CMDQ(n) \ do { \ - if ((pGlamo->cmd_queue_cache->used + 2 * (n)) > \ - pGlamo->cmd_queue_cache->size) { \ - GLAMOFlushCMDQCache(pGlamo, 1); \ + if ((pGlamo->cmd_queue->used + 2 * (n)) > \ + pGlamo->cmd_queue->size) { \ + GLAMODispatchCMDQ(pGlamo); \ } \ - __head = (CARD16 *)((char *)pGlamo->cmd_queue_cache->data + \ - pGlamo->cmd_queue_cache->used); \ + __head = (CARD16 *)((char *)pGlamo->cmd_queue->data + \ + pGlamo->cmd_queue->used); \ __count = 0; \ } while (0) #define END_CMDQ() do { \ - pGlamo->cmd_queue_cache->used += __count * 2; \ + pGlamo->cmd_queue->used += __count * 2; \ } while (0) #define OUT_BURST_REG(reg, val) do { \ @@ -60,12 +60,12 @@ do { \ CARD16 *__head; int __count, __total, __reg, __packet0count #define BEGIN_CMDQ(n) \ do { \ - if ((pGlamo->cmd_queue_cache->used + 2 * (n)) > \ - pGlamo->cmd_queue_cache->size) { \ - GLAMOFlushCMDQCache(pGlamo, 1); \ + if ((pGlamo->cmd_queue->used + 2 * (n)) > \ + pGlamo->cmd_queue->size) { \ + GLAMODispatchCMDQ(pGlamo); \ } \ - __head = (CARD16 *)((char *)pGlamo->cmd_queue_cache->data + \ - pGlamo->cmd_queue_cache->used); \ + __head = (CARD16 *)((char *)pGlamo->cmd_queue->data + \ + pGlamo->cmd_queue->used); \ __count = 0; \ __total = n; \ __reg = 0; \ @@ -75,7 +75,7 @@ do { \ if (__count != __total) \ FatalError("count != total (%d vs %d) at %s:%d\n", \ __count, __total, __FILE__, __LINE__); \ - pGlamo->cmd_queue_cache->used += __count * 2; \ + pGlamo->cmd_queue->used += __count * 2; \ } while (0) #define OUT_BURST_REG(reg, val) do { \ @@ -133,7 +133,7 @@ tv_le(struct timeval *tv1, struct timeval *tv2) void -GLAMOFlushCMDQCache(GlamoPtr pGlamo, Bool discard); +GLAMODispatchCMDQ(GlamoPtr pGlamo); size_t GLAMOCMDQInit(ScrnInfoPtr pScrn, size_t mem_start, size_t mem_size); @@ -147,29 +147,5 @@ GLAMOCMDQDisable(ScrnInfoPtr pScrn); void GLAMOCMDQFini(ScrnInfoPtr pScrn); -enum GLAMOEngine { - GLAMO_ENGINE_CMDQ, - GLAMO_ENGINE_ISP, - GLAMO_ENGINE_2D, - GLAMO_ENGINE_MPEG, - GLAMO_ENGINE_ALL, - NB_GLAMO_ENGINES /*should be the last entry*/ -}; - -void -GLAMOEngineEnable(GlamoPtr pGlamo, enum GLAMOEngine engine); - -void -GLAMOEngineDisable(GlamoPtr pGlamo, enum GLAMOEngine engine); - -void -GLAMOEngineReset(GlamoPtr pGlamo, enum GLAMOEngine engine); - -int -GLAMOEngineBusy(GlamoPtr pGlamo, enum GLAMOEngine engine); - -void -GLAMOEngineWait(GlamoPtr pGlamo, enum GLAMOEngine engine); - #endif /* _GLAMO_DMA_H_ */ diff --git a/src/glamo-draw.c b/src/glamo-draw.c index d0590d3..6d4ea15 100644 --- a/src/glamo-draw.c +++ b/src/glamo-draw.c @@ -31,6 +31,7 @@ #include "glamo-regs.h" #include "glamo-cmdq.h" #include "glamo-draw.h" +#include "glamo-engine.h" static const CARD8 GLAMOSolidRop[16] = { /* GXclear */ 0x00, /* 0 */ @@ -212,7 +213,6 @@ GLAMODrawEnable(ScrnInfoPtr pScrn) GLAMODrawDisable(pScrn); return FALSE; } - GLAMOEngineWait(pGlamo, GLAMO_ENGINE_ALL); return TRUE; @@ -366,7 +366,7 @@ GLAMOExaDoneSolid(PixmapPtr pPix) { ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum]; GlamoPtr pGlamo = GlamoPTR(pScrn); - GLAMOFlushCMDQCache(pGlamo, 1); + GLAMODispatchCMDQ(pGlamo); exaMarkSync(pGlamo->pScreen); } @@ -456,7 +456,7 @@ GLAMOExaDoneCopy(PixmapPtr pDst) { ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; GlamoPtr pGlamo = GlamoPTR(pScrn); - GLAMOFlushCMDQCache(pGlamo, 1); + GLAMODispatchCMDQ(pGlamo); exaMarkSync(pGlamo->pScreen); } @@ -562,6 +562,7 @@ GLAMOExaWaitMarker (ScreenPtr pScreen, int marker) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; GlamoPtr pGlamo = GlamoPTR(pScrn); + GLAMODispatchCMDQ(pGlamo); GLAMOEngineWait(pGlamo, GLAMO_ENGINE_ALL); } diff --git a/src/glamo-stub.c b/src/glamo-stub.c deleted file mode 100644 index 96c712d..0000000 --- a/src/glamo-stub.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include "glamo.h" -#include "klinux.h" - - -extern int use_evdev; - -void -InitCard(char *name) -{ - KdCardAttr attr; - - attr.io = 0; - attr.address[0] = 0x8000000; - attr.naddr = 1; - KdCardInfoAdd(&GLAMOFuncs, &attr, 0); -} - -void -InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) -{ - char *verbosity_str=NULL; - int verbosity=0; - verbosity_str = getenv("VERBOSITY"); - if (!verbosity_str) { - verbosity = 5; - } else { - verbosity = atoi(verbosity_str); - } - LogSetParameter(XLOG_VERBOSITY, verbosity) ; - LogMessage(X_INFO, "verbosity set to %d\n", verbosity); - KdInitOutput(pScreenInfo, argc, argv); -} - -void -InitInput(int argc, char **argv) -{ - if (use_evdev) - KdInitInput (&LinuxEvdevMouseFuncs, &LinuxEvdevKeyboardFuncs); - else - KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs); -#ifdef TOUCHSCREEN - KdAddMouseDriver (&TsFuncs); -#endif -} - -void -ddxUseMsg (void) -{ - KdUseMsg(); -} - -int -ddxProcessArgument(int argc, char **argv, int i) -{ - int ret; - - ret = KdProcessArgument(argc, argv, i); - - return ret; -} diff --git a/src/glamo.h b/src/glamo.h index 8666b66..c5d18c3 100644 --- a/src/glamo.h +++ b/src/glamo.h @@ -99,11 +99,11 @@ typedef struct { size_t ring_len; /* - * cmd queue cache in system memory + * cmd queue in system memory * It is to be flushed to cmd_queue_space * "at once", when we are happy with it. */ - MemBuf *cmd_queue_cache; + MemBuf *cmd_queue; /* What was GLAMOCardInfo */ volatile char *reg_base; -- cgit v1.2.3