summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authorjensowen <jensowen>2002-04-04 18:06:10 +0000
committerjensowen <jensowen>2002-04-04 18:06:10 +0000
commitefbf4245a6e986048a826cbcac4b5bc144c75fab (patch)
tree43de3de42430e15177733de8ca473d719b5b88f1 /xc
parentd27e25bb5399b325d33bd233633913120a2ded24 (diff)
Converted MGA driver suite to the new drmCommand interface.
Diffstat (limited to 'xc')
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/Imakefile3
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c6
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgacontext.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.c53
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgapixel.c13
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c31
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h89
9 files changed, 154 insertions, 60 deletions
diff --git a/xc/lib/GL/mesa/src/drv/mga/Imakefile b/xc/lib/GL/mesa/src/drv/mga/Imakefile
index 65aaa16c7..6eae16c1f 100644
--- a/xc/lib/GL/mesa/src/drv/mga/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/mga/Imakefile
@@ -42,8 +42,7 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/mga/Imakefile,v 1.22 2002/02/23 00:45:50
DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
$(GLXLIBSRC)/dri/drm/xf86drmHash.o \
$(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
- $(GLXLIBSRC)/dri/drm/xf86drmSL.o \
- $(GLXLIBSRC)/dri/drm/xf86drmCompat.o
+ $(GLXLIBSRC)/dri/drm/xf86drmSL.o
#ifdef GlxSoProf
LOSRCS = ../../../../lowpc.c
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
index 2e2983b1a..24cbbbca9 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
@@ -58,8 +58,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <X11/Xlibint.h>
#include <stdio.h>
-#include "drm.h"
-#include "mga_drm.h"
+#include "xf86drm.h"
+#include "xf86drmMga.h"
#include "mga_xmesa.h"
#include "context.h"
#include "matrix.h"
@@ -297,7 +297,7 @@ mgaCreateContext( Display *dpy, const __GLcontextModes *mesaVis,
mgaContextPtr mmesa;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private;
- drm_mga_sarea_t *saPriv=(drm_mga_sarea_t*)(((char*)sPriv->pSAREA)+
+ MGASAREAPrivPtr saPriv=(MGASAREAPrivPtr)(((char*)sPriv->pSAREA)+
mgaScreen->sarea_priv_offset);
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
index 366d4fe5e..83e22c047 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
@@ -35,6 +35,7 @@
#include "dri_util.h"
#include "mtypes.h"
#include "mgaregs.h"
+#include "xf86drmMga.h"
typedef struct mga_screen_private_s {
@@ -59,10 +60,10 @@ typedef struct mga_screen_private_s {
unsigned int dmaOffset;
- unsigned int textureOffset[MGA_NR_TEX_HEAPS];
- unsigned int textureSize[MGA_NR_TEX_HEAPS];
- int logTextureGranularity[MGA_NR_TEX_HEAPS];
- char *texVirtual[MGA_NR_TEX_HEAPS];
+ unsigned int textureOffset[DRM_MGA_NR_TEX_HEAPS];
+ unsigned int textureSize[DRM_MGA_NR_TEX_HEAPS];
+ int logTextureGranularity[DRM_MGA_NR_TEX_HEAPS];
+ char *texVirtual[DRM_MGA_NR_TEX_HEAPS];
__DRIscreenPrivate *sPriv;
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgacontext.h b/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
index fee1adae6..5f00b4bd6 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
@@ -32,7 +32,7 @@
#include <X11/Xlibint.h>
#include "dri_util.h"
#include "mtypes.h"
-#include "drm.h"
+#include "xf86drm.h"
#include "mm.h"
#include "mem.h"
#include "mga_sarea.h"
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
index 4e8d0de81..43b00ac63 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
@@ -45,7 +45,7 @@
#include "mgabuffers.h"
-#include "drm.h"
+#include "xf86drm.h"
#include "xf86drmMga.h"
static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
@@ -53,13 +53,22 @@ static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
int length)
{
drmBufPtr buf = mmesa->iload_buffer;
- int ret;
+ drmMGAIload iload;
+ int ret, i;
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "DRM_IOCTL_MGA_ILOAD idx %d dst %x length %d\n",
buf->idx, (int) dest, length);
- ret = drmMGATextureLoad( mmesa->driFd, buf->idx, dest, length );
+ iload.idx = buf->idx;
+ iload.dstorg = dest;
+ iload.length = length;
+
+ do {
+ ret = drmCommandWrite( mmesa->driFd, DRM_MGA_ILOAD,
+ &iload, sizeof(drmMGAIload) );
+ } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY );
+
if ( ret < 0 ) {
printf("send iload retcode = %d\n", ret);
exit(1);
@@ -155,6 +164,7 @@ mgaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
int ret;
int i;
static int nrclears;
+ drmMGAClearRec clear;
FLUSH_BATCH( mmesa );
@@ -242,9 +252,13 @@ mgaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
mmesa->sarea->nbox = n;
- ret = drmMGAClear( mmesa->driFd, flags,
- clear_color, clear_depth,
- color_mask, depth_mask );
+ clear.flags = flags;
+ clear.clear_color = clear_color;
+ clear.clear_depth = clear_depth;
+ clear.color_mask = color_mask;
+ clear.depth_mask = depth_mask;
+ ret = drmCommandWrite( mmesa->driFd, DRM_MGA_CLEAR,
+ &clear, sizeof(drmMGAClearRec));
if ( ret ) {
fprintf( stderr, "send clear retcode = %d\n", ret );
exit( 1 );
@@ -340,7 +354,7 @@ void mgaSwapBuffers(Display *dpy, void *drawablePrivate)
if (0)
fprintf(stderr, "DRM_IOCTL_MGA_SWAP\n");
- ret = drmMGASwapBuffers( mmesa->driFd );
+ ret = drmCommandNone( mmesa->driFd, DRM_MGA_SWAP );
if ( ret ) {
printf("send swap retcode = %d\n", ret);
exit(1);
@@ -423,6 +437,7 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
XF86DRIClipRectPtr pbox = mmesa->pClipRects;
int nbox = mmesa->numClipRects;
drmBufPtr buffer = mmesa->vertex_dma_buffer;
+ drmMGAVertex vertex;
int i;
mmesa->vertex_dma_buffer = 0;
@@ -457,7 +472,12 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
fprintf(stderr, "Firing vertex -- case a nbox %d\n", nbox);
- drmMGAFlushVertexBuffer( mmesa->driFd, buffer->idx, buffer->used, 1 );
+ vertex.idx = buffer->idx;
+ vertex.used = buffer->used;
+ vertex.discard = 1;
+ drmCommandWrite( mmesa->driFd, DRM_MGA_VERTEX,
+ &vertex, sizeof(drmMGAVertex) );
+
age_mmesa(mmesa, mmesa->sarea->last_enqueue);
}
else
@@ -498,8 +518,13 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa )
discard = 1;
mmesa->sarea->dirty |= MGA_UPLOAD_CLIPRECTS;
- drmMGAFlushVertexBuffer( mmesa->driFd, buffer->idx,
- buffer->used, discard );
+
+ vertex.idx = buffer->idx;
+ vertex.used = buffer->used;
+ vertex.discard = discard;
+ drmCommandWrite( mmesa->driFd, DRM_MGA_VERTEX,
+ &vertex, sizeof(drmMGAVertex) );
+
age_mmesa(mmesa, mmesa->sarea->last_enqueue);
}
}
@@ -575,9 +600,15 @@ void mgaDDFlush( GLcontext *ctx )
void mgaReleaseBufLocked( mgaContextPtr mmesa, drmBufPtr buffer )
{
+ drmMGAVertex vertex;
+
if (!buffer) return;
- drmMGAFlushVertexBuffer( mmesa->driFd, buffer->idx, 0, 1 );
+ vertex.idx = buffer->idx;
+ vertex.used = 0;
+ vertex.discard = 1;
+ drmCommandWrite( mmesa->driFd, DRM_MGA_VERTEX,
+ &vertex, sizeof(drmMGAVertex) );
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgapixel.c b/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
index bebbcb6bc..9b3cee9e2 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
@@ -37,8 +37,7 @@
#include "mgapixel.h"
#include "mgabuffers.h"
-#include "drm.h"
-#include "mga_drm.h"
+#include "xf86drm.h"
#include "xf86drmMga.h"
#include "swrast/swrast.h"
@@ -221,7 +220,7 @@ mgaTryReadPixels( GLcontext *ctx,
GLvoid *pixels )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- drm_mga_blit_t blit;
+ drmMGABlit blit;
GLint size, skipPixels, skipRows;
GLint pitch = pack->RowLength ? pack->RowLength : width;
GLboolean ok;
@@ -354,7 +353,8 @@ mgaTryReadPixels( GLcontext *ctx,
mmesa->sarea->nbox = n;
- if (n && (retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_BLIT, &blit))) {
+ if (n && (retcode = drmCommandWrite( mmesa->driFd, DRM_MGA_BLIT,
+ &blit, sizeof(drmMGABlit)))) {
fprintf(stderr, "blit ioctl failed, retcode = %d\n", retcode);
UNLOCK_HARDWARE( mmesa );
exit(1);
@@ -391,7 +391,7 @@ static void do_draw_pix( GLcontext *ctx,
GLuint dest, GLuint planemask)
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- drm_mga_blit_t blit;
+ drmMGABlit blit;
__DRIdrawablePrivate *dPriv = mmesa->driDrawable;
XF86DRIClipRectPtr pbox = dPriv->pClipRects;
int nbox = dPriv->numClipRects;
@@ -454,7 +454,8 @@ static void do_draw_pix( GLcontext *ctx,
mmesa->sarea->nbox = n;
- if (n && (retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_BLIT, &blit))) {
+ if (n && (retcode = drmCommandWrite( mmesa->driFd, DRM_MGA_BLIT,
+ &blit, sizeof(drmMGABlit)))) {
fprintf(stderr, "blit ioctl failed, retcode = %d\n", retcode);
UNLOCK_HARDWARE( mmesa );
exit(1);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
index 3d7df452b..12572a86c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
@@ -342,13 +342,29 @@ static void MGADestroyContext( ScreenPtr pScreen, drmContext hwContext,
static void MGAWaitForIdleDMA( ScrnInfoPtr pScrn )
{
MGAPtr pMga = MGAPTR(pScrn);
+ drmMGALock lock;
int ret;
int i = 0;
+ memset( &lock, 0, sizeof(drmMGALock) );
+
for (;;) {
do {
- ret = drmMGAFlushDMA( pMga->drmFD,
- DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH );
+ /* first ask for quiescent and flush */
+ lock.flags = DRM_MGA_LOCK_QUIESCENT | DRM_MGA_LOCK_FLUSH;
+ do {
+ ret = drmCommandWrite( pMga->drmFD, DRM_MGA_FLUSH,
+ &lock, sizeof( drmMGALock ) );
+ } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY );
+
+ /* if it's still busy just try quiescent */
+ if ( ret == -EBUSY ) {
+ lock.flags = DRM_MGA_LOCK_QUIESCENT;
+ do {
+ ret = drmCommandWrite( pMga->drmFD, DRM_MGA_FLUSH,
+ &lock, sizeof( drmMGALock ) );
+ } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY );
+ }
} while ( ( ret == -EBUSY ) && ( i++ < MGA_TIMEOUT ) );
if ( ret == 0 )
@@ -357,7 +373,7 @@ static void MGAWaitForIdleDMA( ScrnInfoPtr pScrn )
xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
"[dri] Idle timed out, resetting engine...\n" );
- drmMGAEngineReset( pMga->drmFD );
+ drmCommandNone( pMga->drmFD, DRM_MGA_RESET );
}
}
@@ -846,6 +862,7 @@ static Bool MGADRIKernelInit( ScreenPtr pScreen )
memset( &init, 0, sizeof(drmMGAInit) );
+ init.func = MGA_INIT_DMA;
init.sarea_priv_offset = sizeof(XF86DRISAREARec);
switch ( pMga->Chipset ) {
@@ -888,7 +905,7 @@ static Bool MGADRIKernelInit( ScreenPtr pScreen )
init.texture_offset[1] = pMGADRIServer->agpTextures.handle;
init.texture_size[1] = pMGADRIServer->agpTextures.size;
- ret = drmMGAInitDMA( pMga->drmFD, &init );
+ ret = drmCommandWrite( pMga->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit));
if ( ret < 0 ) {
xf86DrvMsg( pScrn->scrnIndex, X_ERROR,
"[drm] Failed to initialize DMA! (%d)\n", ret );
@@ -1253,13 +1270,17 @@ void MGADRICloseScreen( ScreenPtr pScreen )
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
MGAPtr pMga = MGAPTR(pScrn);
MGADRIServerPrivatePtr pMGADRIServer = pMga->DRIServerInfo;
+ drmMGAInit init;
if ( pMGADRIServer->drmBuffers ) {
drmUnmapBufs( pMGADRIServer->drmBuffers );
pMGADRIServer->drmBuffers = NULL;
}
- drmMGACleanupDMA( pMga->drmFD );
+ /* Cleanup DMA */
+ memset( &init, 0, sizeof(drmMGAInit) );
+ init.func = MGA_CLEANUP_DMA;
+ drmCommandWrite( pMga->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit) );
if ( pMGADRIServer->status.map ) {
drmUnmap( pMGADRIServer->status.map, pMGADRIServer->status.size );
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
index 084e3f16f..19d7b69bc 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
@@ -331,12 +331,12 @@ static const char *drmSymbols[] = {
"drmAgpRelease",
"drmAgpUnbind",
"drmAgpVendorId",
+ "drmCommandNone",
+ "drmCommandRead",
+ "drmCommandWrite",
+ "drmCommandWriteRead",
"drmFreeVersion",
"drmGetVersion",
- "drmMGACleanupDMA",
- "drmMGAEngineReset",
- "drmMGAFlushDMA",
- "drmMGAInitDMA",
"drmMapBufs",
"drmMap",
"drmUnmap",
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h
index 3eb47605d..c93f3a7f2 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h
@@ -8,13 +8,34 @@
* the kernel include file as well (mga_drm.h)
*/
+#define DRM_MGA_IDLE_RETRY 2048
+#define DRM_MGA_NR_TEX_HEAPS 2
+
typedef struct {
int installed;
unsigned long phys_addr;
int size;
} drmMGAWarpIndex;
+/* Driver specific DRM command indices
+ * NOTE: these are not OS specific, but they are driver specific
+ */
+#define DRM_MGA_INIT 0x00
+#define DRM_MGA_FLUSH 0x01
+#define DRM_MGA_RESET 0x02
+#define DRM_MGA_SWAP 0x03
+#define DRM_MGA_CLEAR 0x04
+#define DRM_MGA_VERTEX 0x05
+#define DRM_MGA_INDICES 0x06
+#define DRM_MGA_ILOAD 0x07
+#define DRM_MGA_BLIT 0x08
+
typedef struct {
+ enum {
+ MGA_INIT_DMA = 0x01,
+ MGA_CLEANUP_DMA = 0x02
+ } func;
+
unsigned long sarea_priv_offset;
int chipset;
@@ -29,8 +50,8 @@ typedef struct {
unsigned int depth_cpp;
unsigned int depth_offset, depth_pitch;
- unsigned int texture_offset[2];
- unsigned int texture_size[2];
+ unsigned int texture_offset[DRM_MGA_NR_TEX_HEAPS];
+ unsigned int texture_size[DRM_MGA_NR_TEX_HEAPS];
unsigned long fb_offset;
unsigned long mmio_offset;
@@ -40,32 +61,52 @@ typedef struct {
unsigned long buffers_offset;
} drmMGAInit;
-extern int drmMGAInitDMA( int fd, drmMGAInit *info );
-extern int drmMGACleanupDMA( int fd );
-
-extern int drmMGAFlushDMA( int fd, drmLockFlags flags );
-
-extern int drmMGAEngineReset( int fd );
+typedef enum {
+ DRM_MGA_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */
+ DRM_MGA_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */
+ DRM_MGA_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */
+ DRM_MGA_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */
+ /* These *HALT* flags aren't supported yet
+ -- they will be used to support the
+ full-screen DGA-like mode. */
+ DRM_MGA_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */
+ DRM_MGA_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */
+} drmMGALockFlags;
-extern int drmMGAFullScreen( int fd, int enable );
+typedef struct {
+ int context;
+ drmMGALockFlags flags;
+} drmMGALock;
-extern int drmMGASwapBuffers( int fd );
-extern int drmMGAClear( int fd, unsigned int flags,
- unsigned int clear_color, unsigned int clear_depth,
- unsigned int color_mask, unsigned int depth_mask );
+typedef struct {
+ int idx;
+ unsigned int dstorg;
+ unsigned int length;
+} drmMGAIload;
-extern int drmMGAFlushVertexBuffer( int fd, int indx, int used, int discard );
-extern int drmMGAFlushIndices( int fd, int indx,
- int start, int end, int discard );
+typedef struct {
+ unsigned int flags;
+ unsigned int clear_color;
+ unsigned int clear_depth;
+ unsigned int color_mask;
+ unsigned int depth_mask;
+} drmMGAClearRec;
-extern int drmMGATextureLoad( int fd, int indx,
- unsigned int dstorg, unsigned int length );
+typedef struct {
+ int idx; /* buffer to queue */
+ int used; /* bytes in use */
+ int discard; /* client finished with buffer? */
+} drmMGAVertex;
-extern int drmMGAAgpBlit( int fd, unsigned int planemask,
- unsigned int src, int src_pitch,
- unsigned int dst, int dst_pitch,
- int delta_sx, int delta_sy,
- int delta_dx, int delta_dy,
- int height, int ydir );
+typedef struct {
+ unsigned int planemask;
+ unsigned int srcorg;
+ unsigned int dstorg;
+ int src_pitch, dst_pitch;
+ int delta_sx, delta_sy;
+ int delta_dx, delta_dy;
+ int height, ydir; /* flip image vertically */
+ int source_pitch, dest_pitch;
+} drmMGABlit;
#endif