aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <rob@ti.com>2011-10-20 09:56:11 -0500
committerRob Clark <rob@ti.com>2012-01-13 11:23:36 -0600
commit0fdd91ff3e0975f2c48204be0cb5e15dde8ef751 (patch)
tree49ae72f59a5b640ee3ba0527f4456a5e730e9eca
parent3c3ffd8be924f32e0b26c7090503143f61991fd0 (diff)
shuffle things around for submodules..
-rw-r--r--src/Makefile.am2
-rw-r--r--src/omap_dri2.c12
-rw-r--r--src/omap_driver.c4
-rw-r--r--src/omap_driver.h56
-rw-r--r--src/omap_exa.c (renamed from src/omap_exa_common.c)53
-rw-r--r--src/omap_exa.h (renamed from src/omap_exa_common.h)84
-rw-r--r--src/omap_exa_null.c4
-rw-r--r--src/omap_util.h78
8 files changed, 199 insertions, 94 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 6687697..dea0e6e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,7 +43,7 @@ omap_drv_ladir = @moduledir@/drivers
omap_drv_la_SOURCES = \
drmmode_display.c \
- omap_exa_common.c \
+ omap_exa.c \
omap_exa_null.c \
omap_dri2.c \
omap_driver.c
diff --git a/src/omap_dri2.c b/src/omap_dri2.c
index 944f22e..8a1013c 100644
--- a/src/omap_dri2.c
+++ b/src/omap_dri2.c
@@ -31,7 +31,7 @@
#endif
#include "omap_driver.h"
-#include "omap_exa_common.h"
+#include "omap_exa.h"
#include "xf86drmMode.h"
#include "dri2.h"
@@ -64,16 +64,6 @@ typedef struct {
#define DRIBUF(p) ((DRI2BufferPtr)(&(p)->base))
-static inline PixmapPtr
-draw2pix(DrawablePtr pDraw)
-{
- if (pDraw->type == DRAWABLE_WINDOW) {
- return pDraw->pScreen->GetWindowPixmap((WindowPtr)pDraw);
- } else {
- return (PixmapPtr)pDraw;
- }
-}
-
static inline DrawablePtr
dri2draw(DrawablePtr pDraw, DRI2BufferPtr buf)
{
diff --git a/src/omap_driver.c b/src/omap_driver.c
index 34424ea..3d8b412 100644
--- a/src/omap_driver.c
+++ b/src/omap_driver.c
@@ -644,7 +644,7 @@ OMAPAccelInit(ScreenPtr pScreen)
case 0x4430:
case 0x4460:
INFO_MSG("Initializing the \"%s\" sub-module ...", SUB_MODULE_PVR);
- pOMAP->pOMAPEXA = InitPowerVREXA(pScreen, pScrn);
+ pOMAP->pOMAPEXA = InitPowerVREXA(pScreen, pScrn, pOMAP->drmFD);
if (pOMAP->pOMAPEXA) {
INFO_MSG("Successfully initialized the \"%s\" sub-module",
SUB_MODULE_PVR);
@@ -662,7 +662,7 @@ OMAPAccelInit(ScreenPtr pScreen)
}
if (!pOMAP->pOMAPEXA) {
- pOMAP->pOMAPEXA = InitNullEXA(pScreen, pScrn);
+ pOMAP->pOMAPEXA = InitNullEXA(pScreen, pScrn, pOMAP->drmFD);
}
if (pOMAP->dri && pOMAP->pOMAPEXA) {
diff --git a/src/omap_driver.h b/src/omap_driver.h
index f4300d6..d4beaef 100644
--- a/src/omap_driver.h
+++ b/src/omap_driver.h
@@ -27,8 +27,8 @@
* Rob Clark <rob@ti.com>
*/
-#ifndef OMAP_DRV_H_
-#define OMAP_DRV_H_
+#ifndef __OMAP_DRV_H__
+#define __OMAP_DRV_H__
/* All drivers need the following headers: */
#include "xf86.h"
@@ -61,6 +61,8 @@
#include <errno.h>
+#include "omap_exa.h"
+
#define OMAP_VERSION 1000 /* Apparently not used by X server */
#define OMAP_NAME "OMAP" /* Name used to prefix messages */
@@ -114,41 +116,6 @@ extern unsigned int
OMAPCalculateTiledStride(unsigned int width, unsigned int bitsPerPixel);
-/**
- * A per-Screen structure used to communicate and coordinate between the OMAP X
- * driver and an external EXA sub-module (if loaded).
- */
-typedef struct _OMAPEXARec
-{
- union { struct {
-
- /**
- * Called by X driver's CloseScreen() function at the end of each server
- * generation to free per-Screen data structures (except those held by
- * pScrn).
- */
- Bool (*CloseScreen)(int scrnIndex, ScreenPtr pScreen);
-
- /**
- * Called by X driver's FreeScreen() function at the end of each server
- * lifetime to free per-ScrnInfoRec data structures, to close any external
- * connections (e.g. with PVR2D, DRM), etc.
- */
- void (*FreeScreen)(int scrnIndex, int flags);
-
- /* add new fields here at end, to preserve ABI */
-
- };
-
- /* padding to keep ABI stable, so an existing EXA submodule
- * doesn't need to be recompiled when new fields are added
- */
- void *pad[64];
- };
-
-} OMAPEXARec, *OMAPEXAPtr;
-
-
/** The driver's Screen-specific, "private" data structure. */
typedef struct _OMAPRec
@@ -222,19 +189,6 @@ typedef struct _OMAPRec
}
/**
- * Canonical name of an external sub-module providing support for EXA
- * acceleration, that utiltizes the OMAP's PowerVR accelerator and uses closed
- * source from Imaginations Technology Limited.
- */
-#define SUB_MODULE_PVR "omap_pvr"
-OMAPEXAPtr InitPowerVREXA(ScreenPtr pScreen, ScrnInfoPtr pScrn);
-
-/**
- * Fallback EXA implementation
- */
-OMAPEXAPtr InitNullEXA(ScreenPtr pScreen, ScrnInfoPtr pScrn);
-
-/**
* drmmode functions..
*/
Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp);
@@ -254,4 +208,4 @@ Bool OMAPDRI2ScreenInit(ScreenPtr pScreen);
void OMAPDRI2CloseScreen(ScreenPtr pScreen);
void OMAPDRI2SwapComplete(OMAPDRISwapCmd *cmd);
-#endif /* OMAP_DRV_H_ */
+#endif /* __OMAP_DRV_H__ */
diff --git a/src/omap_exa_common.c b/src/omap_exa.c
index 2e8d644..53e724b 100644
--- a/src/omap_exa_common.c
+++ b/src/omap_exa.c
@@ -30,12 +30,18 @@
#include "config.h"
#endif
-#include "omap_exa_common.h"
-
-
-#define pix2scrn(pPixmap) \
- xf86Screens[(pPixmap)->drawable.pScreen->myNum]
+#include "omap_exa.h"
+#include "omap_driver.h"
+/* keep this here, instead of static-inline so submodule doesn't
+ * need to know layout of OMAPPtr..
+ */
+_X_EXPORT OMAPEXAPtr
+OMAPEXAPTR(ScrnInfoPtr pScrn)
+{
+ OMAPPtr pOMAP = OMAPPTR(pScrn);
+ return pOMAP->pOMAPEXA;
+}
/* Common OMAP EXA functions, mostly related to pixmap/buffer allocation.
* Individual driver submodules can use these directly, or wrap them with
@@ -43,7 +49,17 @@
* can use OMAPPrixmapPrivPtr#priv for their own private data.
*/
-void *
+/* used by DRI2 code to play buffer switcharoo */
+void
+OMAPPixmapExchange(PixmapPtr a, PixmapPtr b)
+{
+ OMAPPixmapPrivPtr apriv = exaGetPixmapDriverPrivate(a);
+ OMAPPixmapPrivPtr bpriv = exaGetPixmapDriverPrivate(b);
+ exchange(apriv->priv, bpriv->priv);
+ exchange(apriv->bo, bpriv->bo);
+}
+
+_X_EXPORT void *
OMAPCreatePixmap (ScreenPtr pScreen, int width, int height,
int depth, int usage_hint, int bitsPerPixel,
int *new_fb_pitch)
@@ -55,19 +71,17 @@ OMAPCreatePixmap (ScreenPtr pScreen, int width, int height,
return priv;
}
-void
+_X_EXPORT void
OMAPDestroyPixmap(ScreenPtr pScreen, void *driverPriv)
{
OMAPPixmapPrivPtr priv = driverPriv;
- if (priv->bo) {
- omap_bo_del(priv->bo);
- }
+ omap_bo_del(priv->bo);
free(priv);
}
-Bool
+_X_EXPORT Bool
OMAPModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
int depth, int bitsPerPixel, int devKind,
pointer pPixData)
@@ -75,7 +89,7 @@ OMAPModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
OMAPPixmapPrivPtr priv = exaGetPixmapDriverPrivate(pPixmap);
ScrnInfoPtr pScrn = pix2scrn(pPixmap);
OMAPPtr pOMAP = OMAPPTR(pScrn);
- uint32_t size, flags = 0;
+ uint32_t size, flags = OMAP_BO_WC;
Bool ret;
ret = miModifyPixmapHeader(pPixmap, width, height, depth,
@@ -152,7 +166,12 @@ OMAPModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
}
}
- return TRUE;
+ if (!priv->bo) {
+ DEBUG_MSG("failed to allocate %dx%d bo, size=%d, flags=%08x",
+ width, height, size, flags);
+ }
+
+ return priv->bo != NULL;
}
/**
@@ -160,7 +179,7 @@ OMAPModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
* performed during OMAPPrepareAccess so this function does not
* have anything to do at present
*/
-void
+_X_EXPORT void
OMAPWaitMarker(ScreenPtr pScreen, int marker)
{
/* no-op */
@@ -214,7 +233,7 @@ static inline enum omap_gem_op idx2op(int index)
* @return FALSE if PrepareAccess() is unsuccessful and EXA should use
* DownloadFromScreen() to migate the pixmap out.
*/
-Bool
+_X_EXPORT Bool
OMAPPrepareAccess(PixmapPtr pPixmap, int index)
{
OMAPPixmapPrivPtr priv = exaGetPixmapDriverPrivate(pPixmap);
@@ -249,7 +268,7 @@ OMAPPrepareAccess(PixmapPtr pPixmap, int index)
* pixmap set up by PrepareAccess(). Note that the FinishAccess() will not be
* called if PrepareAccess() failed and the pixmap was migrated out.
*/
-void
+_X_EXPORT void
OMAPFinishAccess(PixmapPtr pPixmap, int index)
{
OMAPPixmapPrivPtr priv = exaGetPixmapDriverPrivate(pPixmap);
@@ -276,7 +295,7 @@ OMAPFinishAccess(PixmapPtr pPixmap, int index)
* will need to be wrapped by PrepareAccess()/FinishAccess() when accessing it
* with the CPU.
*/
-Bool
+_X_EXPORT Bool
OMAPPixmapIsOffscreen(PixmapPtr pPixmap)
{
/* offscreen means in 'gpu accessible memory', not that it's off the
diff --git a/src/omap_exa_common.h b/src/omap_exa.h
index eb6bb30..9ad11df 100644
--- a/src/omap_exa_common.h
+++ b/src/omap_exa.h
@@ -29,9 +29,81 @@
#ifndef OMAP_EXA_COMMON_H_
#define OMAP_EXA_COMMON_H_
-#include "omap_driver.h"
+/* note: don't include "omap_driver.h" here.. we want to keep some
+ * isolation between structs shared with submodules and stuff internal
+ * to core driver..
+ */
+#include <omap_drmif.h>
+#include "omap_util.h"
#include "exa.h"
+/**
+ * A per-Screen structure used to communicate and coordinate between the OMAP X
+ * driver and an external EXA sub-module (if loaded).
+ */
+typedef struct _OMAPEXARec
+{
+ union { struct {
+
+ /**
+ * Called by X driver's CloseScreen() function at the end of each server
+ * generation to free per-Screen data structures (except those held by
+ * pScrn).
+ */
+ Bool (*CloseScreen)(int scrnIndex, ScreenPtr pScreen);
+
+ /**
+ * Called by X driver's FreeScreen() function at the end of each server
+ * lifetime to free per-ScrnInfoRec data structures, to close any external
+ * connections (e.g. with PVR2D, DRM), etc.
+ */
+ void (*FreeScreen)(int scrnIndex, int flags);
+
+ /* add new fields here at end, to preserve ABI */
+
+
+ /* padding to keep ABI stable, so an existing EXA submodule
+ * doesn't need to be recompiled when new fields are added
+ */
+ }; void *pad[64]; };
+
+} OMAPEXARec, *OMAPEXAPtr;
+
+
+/**
+ * Canonical name of an external sub-module providing support for EXA
+ * acceleration, that utiltizes the OMAP's PowerVR accelerator and uses closed
+ * source from Imaginations Technology Limited.
+ */
+#define SUB_MODULE_PVR "omap_pvr"
+OMAPEXAPtr InitPowerVREXA(ScreenPtr pScreen, ScrnInfoPtr pScrn, int fd);
+
+/**
+ * Fallback EXA implementation
+ */
+OMAPEXAPtr InitNullEXA(ScreenPtr pScreen, ScrnInfoPtr pScrn, int fd);
+
+
+OMAPEXAPtr OMAPEXAPTR(ScrnInfoPtr pScrn);
+
+static inline ScrnInfoPtr
+pix2scrn(PixmapPtr pPixmap)
+{
+ return xf86Screens[(pPixmap)->drawable.pScreen->myNum];
+}
+
+static inline PixmapPtr
+draw2pix(DrawablePtr pDraw)
+{
+ if (!pDraw) {
+ return NULL;
+ } else if (pDraw->type == DRAWABLE_WINDOW) {
+ return pDraw->pScreen->GetWindowPixmap((WindowPtr)pDraw);
+ } else {
+ return (PixmapPtr)pDraw;
+ }
+}
+
/* Common OMAP EXA functions, mostly related to pixmap/buffer allocation.
* Individual driver submodules can use these directly, or wrap them with
* there own functions if anything additional is required. Submodules
@@ -66,14 +138,6 @@ OMAPPixmapBo(PixmapPtr pPixmap)
return priv->bo;
}
-/* used by DRI2 code to play buffer switcharoo */
-static inline void
-OMAPPixmapExchange(PixmapPtr a, PixmapPtr b)
-{
- OMAPPixmapPrivPtr apriv = exaGetPixmapDriverPrivate(a);
- OMAPPixmapPrivPtr bpriv = exaGetPixmapDriverPrivate(b);
- exchange(apriv->priv, bpriv->priv);
- exchange(apriv->bo, bpriv->bo);
-}
+void OMAPPixmapExchange(PixmapPtr a, PixmapPtr b);
#endif /* OMAP_EXA_COMMON_H_ */
diff --git a/src/omap_exa_null.c b/src/omap_exa_null.c
index 524045b..b6cdb9d 100644
--- a/src/omap_exa_null.c
+++ b/src/omap_exa_null.c
@@ -31,7 +31,7 @@
#endif
#include "omap_driver.h"
-#include "omap_exa_common.h"
+#include "omap_exa.h"
#include "exa.h"
@@ -93,7 +93,7 @@ FreeScreen(int scrnIndex, int flags)
OMAPEXAPtr
-InitNullEXA(ScreenPtr pScreen, ScrnInfoPtr pScrn)
+InitNullEXA(ScreenPtr pScreen, ScrnInfoPtr pScrn, int fd)
{
OMAPNullEXAPtr null_exa = calloc(sizeof (*null_exa), 1);
OMAPEXAPtr omap_exa = (OMAPEXAPtr)null_exa;
diff --git a/src/omap_util.h b/src/omap_util.h
new file mode 100644
index 0000000..1e19f67
--- /dev/null
+++ b/src/omap_util.h
@@ -0,0 +1,78 @@
+/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
+
+/*
+ * Copyright © 2011 Texas Instruments, Inc
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors:
+ * Ian Elliott <ianelliottus@yahoo.com>
+ * Rob Clark <rob@ti.com>
+ */
+
+#ifndef __OMAP_UTIL_H__
+#define __OMAP_UTIL_H__
+
+/* All drivers need the following headers: */
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+/**
+ * This controls whether debug statements (and function "trace" enter/exit)
+ * messages are sent to the log file (TRUE) or are ignored (FALSE).
+ */
+extern _X_EXPORT Bool omapDebug;
+
+
+/* Various logging/debug macros for use in the X driver and the external
+ * sub-modules:
+ */
+#define TRACE_ENTER() \
+ do { if (omapDebug) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s:%d: Entering\n",\
+ __FUNCTION__, __LINE__); } while (0)
+#define TRACE_EXIT() \
+ do { if (omapDebug) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s:%d: Exiting\n",\
+ __FUNCTION__, __LINE__); } while (0)
+#define DEBUG_MSG(fmt, ...) \
+ do { if (omapDebug) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s:%d " fmt "\n",\
+ __FUNCTION__, __LINE__, ##__VA_ARGS__); } while (0)
+#define INFO_MSG(fmt, ...) \
+ do { xf86DrvMsg(pScrn->scrnIndex, X_INFO, fmt "\n",\
+ ##__VA_ARGS__); } while (0)
+#define CONFIG_MSG(fmt, ...) \
+ do { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, fmt "\n",\
+ ##__VA_ARGS__); } while (0)
+#define WARNING_MSG(fmt, ...) \
+ do { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "WARNING: " fmt "\n",\
+ ##__VA_ARGS__); } while (0)
+#define ERROR_MSG(fmt, ...) \
+ do { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ERROR: " fmt "\n",\
+ ##__VA_ARGS__); } while (0)
+#define EARLY_ERROR_MSG(fmt, ...) \
+ do { xf86Msg(X_ERROR, "ERROR: " fmt "\n",\
+ ##__VA_ARGS__); } while (0)
+
+
+extern unsigned int
+OMAPCalculateStride(unsigned int fbWidth, unsigned int bitsPerPixel);
+extern unsigned int
+OMAPCalculateTiledStride(unsigned int width, unsigned int bitsPerPixel);
+
+#endif /* __OMAP_UTIL_H__ */