Unichrome DRI:

Updated the driver to the new VIA security mechanisms in DRM. All command
submissions now passes through DRM ioctls. If the DRM AGP ring-buffer is
not enabled, it will use a DRM mechanism for submitting commands to the
hardware via a PCI bus mechanism.

Removed all direct write accesses to the hardware. Among other things the
VQ was previously turned off for the PCI path, apparently for Tuxracer.
That seemed unneeded and was removed. No visible impact on Tuxracer.

Abstracted all buffer blit operations in via_ioctl.c. The blitter context
is now reprogrammed before each blitting operation.

Updated driver date and drm version requirement.
(Bugzilla Bug #1950, Thomas Hellstrm)
This commit is contained in:
Thomas Hellström 2004-12-15 21:59:25 +00:00
parent b4f58e99eb
commit 20456d6a3d
9 changed files with 421 additions and 1137 deletions

View file

@ -60,7 +60,7 @@
#include <stdio.h>
#include "macros.h"
#define DRIVER_DATE "20040923"
#define DRIVER_DATE "20041215"
#include "utils.h"
@ -252,7 +252,7 @@ void viaReAllocateBuffers(GLframebuffer *drawbuffer)
{
GLcontext *ctx;
viaContextPtr vmesa = current_mesa;
ctx = vmesa->glCtx;
ctx->DrawBuffer->Width = drawbuffer->Width;
ctx->DrawBuffer->Height = drawbuffer->Height;
@ -326,7 +326,7 @@ AllocateDmaBuffer(const GLvisual *visual, viaContextPtr vmesa)
#ifdef DEBUG
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
#endif
if (vmesa->dma[0].map && vmesa->dma[1].map)
if (vmesa->dma)
via_free_dma_buffer(vmesa);
if (!via_alloc_dma_buffer(vmesa)) {
@ -350,22 +350,15 @@ InitVertexBuffer(viaContextPtr vmesa)
{
GLuint *addr;
addr = (GLuint *)vmesa->dma[0].map;
*addr = 0xF210F110;
*addr = (HC_ParaType_NotTex << 16);
*addr = 0xcccccccc;
*addr = 0xdddddddd;
addr = (GLuint *)vmesa->dma[1].map;
addr = (GLuint *)vmesa->dma;
*addr = 0xF210F110;
*addr = (HC_ParaType_NotTex << 16);
*addr = 0xcccccccc;
*addr = 0xdddddddd;
vmesa->dmaIndex = 0;
vmesa->dmaLow = DMA_OFFSET;
vmesa->dmaHigh = vmesa->dma[0].size;
vmesa->dmaAddr = (unsigned char *)vmesa->dma[0].map;
vmesa->dmaHigh = VIA_DMA_BUFSIZ;
vmesa->dmaAddr = (unsigned char *)vmesa->dma;
vmesa->dmaLastPrim = vmesa->dmaLow;
}
@ -381,7 +374,7 @@ FreeBuffer(viaContextPtr vmesa)
if (vmesa->depth.map)
via_free_depth_buffer(vmesa);
if (vmesa->dma[0].map && vmesa->dma[1].map)
if (vmesa->dma)
via_free_dma_buffer(vmesa);
}
@ -534,9 +527,6 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->CurrentTexObj[0] = 0;
vmesa->CurrentTexObj[1] = 0;
vmesa->dma[0].size = DMA_SIZE * 1024 * 1024;
vmesa->dma[1].size = DMA_SIZE * 1024 * 1024;
_math_matrix_ctr(&vmesa->ViewportMatrix);
driInitExtensions( ctx, card_extensions, GL_TRUE );
@ -640,34 +630,14 @@ void
viaDestroyContext(__DRIcontextPrivate *driContextPriv)
{
viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate;
/*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private;
#ifdef DEBUG
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
#endif
assert(vmesa); /* should never be null */
viaFlushPrimsLocked(vmesa);
WAIT_IDLE
/*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/
/* Enable VQ */
if (viaScreen->VQEnable) {
*vmesa->regTranSet = 0x00fe0000;
*vmesa->regTranSet = 0x00fe0000;
*vmesa->regTranSpace = 0x00000006;
*vmesa->regTranSpace = 0x40008c0f;
*vmesa->regTranSpace = 0x44000000;
*vmesa->regTranSpace = 0x45080c04;
*vmesa->regTranSpace = 0x46800408;
}
if (vmesa) {
/*=* John Sheng [2003.5.31] flip *=*/
if(vmesa->doPageFlip) {
*((volatile GLuint *)((GLuint)vmesa->regMMIOBase + 0x43c)) = 0x00fe0000;
*((volatile GLuint *)((GLuint)vmesa->regMMIOBase + 0x440)) = 0x00001004;
WAIT_IDLE
*((volatile GLuint *)((GLuint)vmesa->regMMIOBase + 0x214)) = 0;
}
/*=* John Sheng [2003.5.31] agp tex *=*/
if(VIA_DEBUG) fprintf(stderr, "agpFullCount = %d\n", agpFullCount);

View file

@ -70,6 +70,8 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
#define VIA_UPLOAD_ENABLE 0x0800
#define VIA_UPLOAD_ALL 0x1000
#define VIA_DMA_BUFSIZ 500000
/* Use the templated vertex formats:
*/
#define TAG(x) via##x
@ -99,13 +101,6 @@ typedef struct {
char *map;
} viaBuffer, *viaBufferPtr;
typedef struct {
drm_handle_t handle;
drmSize size;
GLuint offset;
GLuint index;
unsigned char* map;
} viaDmaBuffer, *viaDmaBufferPtr;
struct via_context_t {
GLint refcount;
@ -121,7 +116,7 @@ struct via_context_t {
GLboolean hasAccum;
GLuint depthBits;
GLuint stencilBits;
viaDmaBuffer dma[2];
GLuint *dma;
viaRegion tex;
GLuint isAGP;
@ -157,7 +152,6 @@ struct via_context_t {
/* drmBufPtr dma_buffer;
*/
unsigned char* dmaAddr;
GLuint dmaIndex;
GLuint dmaLow;
GLuint dmaHigh;
GLuint dmaLastPrim;
@ -297,8 +291,6 @@ struct via_context_t {
volatile GLuint* regTranSpace;
GLuint* agpBase;
GLuint drawType;
/*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/
int VQEnable;
};
/*#define DMA_OFFSET 16*/
#define DMA_OFFSET 32

View file

@ -27,6 +27,7 @@
#include "via_context.h"
#include "via_ioctl.h"
#include "via_fb.h"
#include "xf86drm.h"
#include <sys/ioctl.h>
GLboolean
@ -170,101 +171,38 @@ via_free_depth_buffer(viaContextPtr vmesa)
GLboolean
via_alloc_dma_buffer(viaContextPtr vmesa)
{
drm_via_mem_t fb;
drmVIADMABuf dma;
drmVIADMAInit init;
#ifdef DEBUG
if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
#endif
if (vmesa->viaScreen->agpLinearStart) {
/* Allocate DMA in AGP memory*/
fb.context = vmesa->hHWContext;
fb.size = vmesa->dma[0].size;
fb.type = AGP;
if (!ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb)) {
vmesa->dma[0].offset = fb.offset;
vmesa->dma[0].index = fb.index;
vmesa->dma[0].map = (unsigned char *)((GLuint)vmesa->viaScreen->agpLinearStart + fb.offset);
if (!ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb)) {
vmesa->dma[1].offset = fb.offset;
vmesa->dma[1].index = fb.index;
vmesa->dma[1].map = (unsigned char *)((GLuint)vmesa->viaScreen->agpLinearStart + fb.offset);
vmesa->useAgp = GL_TRUE;
return GL_TRUE;
}
else {
/* release dma[0]*/
return GL_FALSE;
}
}
return GL_FALSE;
}
else {
/* Allocate DMA in System memory */
dma.size = vmesa->dma[0].size;
vmesa->dma = (GLuint *) malloc(VIA_DMA_BUFSIZ);
/*
* Check whether AGP DMA has been initialized.
*/
if (drmVIAAllocateDMA(vmesa->driFd,&dma) < 0) {
return GL_FALSE;
}
vmesa->dma[0].offset = 0;
vmesa->dma[0].map = (unsigned char *)dma.address;
vmesa->dma[0].index = dma.index;
drmVIAAllocateDMA(vmesa->driFd, &dma);
vmesa->dma[1].offset = 0;
vmesa->dma[1].map = (unsigned char *)dma.address;
vmesa->dma[1].index = dma.index;
vmesa->useAgp = GL_FALSE;
return GL_TRUE;
}
init.func = VIA_DMA_INITIALIZED;
vmesa->useAgp =
( 0 == drmCommandWrite(vmesa->driFd, DRM_VIA_DMA_INIT,
&init, sizeof(init)));
if (vmesa->useAgp)
printf("unichrome_dri.so: Using AGP.\n");
else
printf("unichrome_dri.so: Using PCI.\n");
#ifdef DEBUG
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
#endif
return ((vmesa->dma) ? GL_TRUE : GL_FALSE);
}
void
via_free_dma_buffer(viaContextPtr vmesa)
{
drmVIADMABuf dma;
drm_via_mem_t fb;
if (!vmesa) return;
/* Release AGP command buffer */
if (vmesa->useAgp) {
fb.context = vmesa->hHWContext;
fb.index = vmesa->dma[0].index;
fb.type = AGP;
ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb);
vmesa->dma[0].map = NULL;
fb.index = vmesa->dma[1].index;
ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb);
vmesa->dma[1].map = NULL;
}
/* Release System command buffer */
else {
/*=* John Sheng [2003.7.18] viewperf frames/sec *=*/
/*dma.address = (unsigned long *)vmesa->dma[0].offset;*/
dma.address = (unsigned long *)vmesa->dma[0].map;
/*=* John Sheng [2003.6.16] fix pci path *=*/
dma.size = (unsigned int)vmesa->dma[0].size;
drmVIAReleaseDMA(vmesa->driFd, &dma);
/*=* John Sheng [2003.7.18] viewperf frames/sec *=*/
/*dma.address = (unsigned long *)vmesa->dma[1].offset;*/
dma.address = (unsigned long *)vmesa->dma[1].map;
/*=* John Sheng [2003.6.16] fix pci path *=*/
dma.size = (unsigned int)vmesa->dma[1].size;
drmVIAReleaseDMA(vmesa->driFd, &dma);
/*=* John Sheng [2003.7.18] viewperf frames/sec *=*/
/*vmesa->dma[0].offset = 0;
vmesa->dma[1].offset = 0;*/
vmesa->dma[0].map = 0;
vmesa->dma[1].map = 0;
}
free(vmesa->dma);
vmesa->dma = 0;
}
GLboolean

File diff suppressed because it is too large Load diff

View file

@ -179,7 +179,7 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
tnl->Driver.Render.Finish(ctx);
/*=* DBG - viewperf7.0 : fix command buffer overflow *=*/
if (vmesa->dmaLow > (vmesa->dma[0].size / 2))
if (vmesa->dmaLow > (VIA_DMA_BUFSIZ / 2))
viaFlushPrims(vmesa);
#ifdef DEBUG
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
@ -468,7 +468,7 @@ static GLboolean via_run_render(GLcontext *ctx,
}*/
/*=* DBG viewperf7.0 : fix command buffer overflow *=*/
if (vmesa->dmaLow > (vmesa->dma[0].size / 2))
if (vmesa->dmaLow > (VIA_DMA_BUFSIZ / 2))
viaFlushPrims(vmesa);
#ifdef DEBUG
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);

View file

@ -95,8 +95,6 @@ viaInitDriver(__DRIscreenPrivate *sPriv)
#ifdef USE_XINERAMA
viaScreen->drixinerama = gDRIPriv->drixinerama;
#endif
/*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/
viaScreen->VQEnable = gDRIPriv->VQEnable;
#ifdef DEBUG
if (VIA_DEBUG) {
fprintf(stderr, "deviceID = %08x\n", viaScreen->deviceID);
@ -390,7 +388,7 @@ void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc
__DRIscreenPrivate *psp;
static const __DRIversion ddx_expected = { 4, 0, 0 };
static const __DRIversion dri_expected = { 4, 0, 0 };
static const __DRIversion drm_expected = { 2, 0, 0 };
static const __DRIversion drm_expected = { 2, 3, 0 };
if ( ! driCheckDriDdxDrmVersions2( "Unichrome",
dri_version, & dri_expected,

View file

@ -253,7 +253,7 @@ static void viaDeleteTexture(GLcontext *ctx, struct gl_texture_object *texObj)
if (vmesa) {
/*=* John Sheng [2003.7.18] viewperf frames/sec *=*/
/*VIA_FIREVERTICES(vmesa);*/
if (vmesa->dma[0].map) { /* imply vmesa is not under destroying */
if (vmesa->dma) { /* imply vmesa is not under destroying */
VIA_FIREVERTICES(vmesa);
}
viaDestroyTexObj(vmesa, t);

View file

@ -131,3 +131,13 @@ int drmVIAReleaseDMA(int fd, drmVIADMABuf *buf)
return 0;
}
int drmVIACmdBuffer(int fd, drmVIACommandBuffer *buf)
{
if (ioctl(fd, 0x48, buf ) < 0) {
return -errno;
}
else
return 0;
}

View file

@ -25,6 +25,19 @@
#ifndef __XF86DRI_VIA_H__
#define __XF86DRI_VIA_H__
#define DRM_VIA_ALLOCMEM 0x00
#define DRM_VIA_FREEMEM 0x01
#define DRM_VIA_AGP_INIT 0x02
#define DRM_VIA_FB_INIT 0x03
#define DRM_VIA_MAP_INIT 0x04
#define DRM_VIA_DEC_FUTEX 0x05
#define NOT_USED
#define DRM_VIA_DMA_INIT 0x07
#define DRM_VIA_CMDBUFFER 0x08
#define DRM_VIA_FLUSH 0x09
#define DRM_VIA_PCICMD 0x0a
#define DRM_VIA_CMDBUF_SIZE 0x0b
typedef struct {
unsigned long sarea_priv_offset;
unsigned long fb_offset;
@ -45,10 +58,44 @@ typedef struct {
unsigned long *address;
} drmVIADMABuf;
typedef struct {
char *buf;
unsigned long size;
} drmVIACommandBuffer;
typedef struct {
enum {
VIA_CMDBUF_SPACE = 0x01,
VIA_CMDBUF_LAG = 0x02
} func;
int wait;
unsigned size;
} drmVIACmdBufSize;
typedef struct {
unsigned int offset;
unsigned int size;
unsigned long index;
int discard; /* client is finished with the buffer? */
} drmVIAFlush;
typedef struct{
enum {
VIA_INIT_DMA = 0x01,
VIA_CLEANUP_DMA = 0x02,
VIA_DMA_INITIALIZED = 0x03
} func;
unsigned long offset;
unsigned long size;
unsigned long reg_pause_addr;
} drmVIADMAInit;
extern int drmVIAAgpInit(int fd, int offset, int size);
extern int drmVIAFBInit(int fd, int offset, int size);
extern int drmVIAInitMAP(int fd, drmVIAInit *info);
extern int drmVIAAllocateDMA(int fd, drmVIADMABuf *buf);
extern int drmVIAReleaseDMA(int fd, drmVIADMABuf *buf);
#endif