nouveau: match drm changes (0.0.7)

This commit is contained in:
Ben Skeggs
2007-06-10 03:05:05 +10:00
committed by Ben Skeggs
parent 17e81bda6e
commit 5e4a0f42f2
14 changed files with 94 additions and 139 deletions

View File

@@ -41,7 +41,7 @@ nouveau_bo_download_from_screen(GLcontext *ctx, GLuint offset, GLuint size,
DEBUG("..sys_mem\n");
in_mem = nouveau_mem_alloc(ctx, NOUVEAU_MEM_AGP, size, 0);
if (in_mem) {
DEBUG("....via AGP\n");
DEBUG("....via GART\n");
/* otherwise, try blitting to faster memory and
* copying from there
*/
@@ -86,7 +86,7 @@ nouveau_bo_upload_to_screen(GLcontext *ctx, GLuint offset, GLuint size,
NOUVEAU_MEM_MAPPED,
size, 0);
if (out_mem) {
DEBUG("....via AGP\n");
DEBUG("....via GART\n");
_mesa_memcpy(out_mem->map,
nbo->cpu_mem_sys + offset, size);
nouveau_memformat_flat_emit(ctx, nbo->gpu_mem, out_mem,
@@ -511,7 +511,7 @@ nouveauBufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size,
gpu_flags = 0;
break;
default:
gpu_flags = NOUVEAU_BO_VRAM_OK | NOUVEAU_BO_AGP_OK;
gpu_flags = NOUVEAU_BO_VRAM_OK | NOUVEAU_BO_GART_OK;
break;
}
nouveau_bo_init_storage(ctx, gpu_flags, size, data, usage, obj);

View File

@@ -5,7 +5,7 @@
#include "nouveau_buffers.h"
#define NOUVEAU_BO_VRAM_OK (NOUVEAU_MEM_FB | NOUVEAU_MEM_FB_ACCEPTABLE)
#define NOUVEAU_BO_AGP_OK (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE)
#define NOUVEAU_BO_GART_OK (NOUVEAU_MEM_AGP | NOUVEAU_MEM_AGP_ACCEPTABLE)
typedef struct nouveau_bufferobj_region_t {
uint32_t start;

View File

@@ -32,8 +32,8 @@ nouveau_memformat_flat_emit(GLcontext *ctx,
return GL_FALSE;
}
src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaAGP;
dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaAGP;
src_handle = (src->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT;
dst_handle = (dst->type & NOUVEAU_MEM_FB) ? NvDmaFB : NvDmaTT;
src_offset += nouveau_mem_gpu_offset_get(ctx, src);
dst_offset += nouveau_mem_gpu_offset_get(ctx, dst);
@@ -138,7 +138,7 @@ nouveau_mem_gpu_offset_get(GLcontext *ctx, nouveau_mem *mem)
if (mem->type & NOUVEAU_MEM_FB)
return (uint32_t)mem->offset - nmesa->vram_phys;
else if (mem->type & NOUVEAU_MEM_AGP)
return (uint32_t)mem->offset - nmesa->agp_phys;
return (uint32_t)mem->offset - nmesa->gart_phys;
else
return 0xDEADF00D;
}

View File

@@ -145,10 +145,10 @@ GLboolean nouveauCreateContext( const __GLcontextModes *glVisual,
&nmesa->vram_size))
return GL_FALSE;
if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_PHYSICAL,
&nmesa->agp_phys))
&nmesa->gart_phys))
return GL_FALSE;
if (!nouveauDRMGetParam(nmesa, NOUVEAU_GETPARAM_AGP_SIZE,
&nmesa->agp_size))
&nmesa->gart_size))
return GL_FALSE;
if (!nouveauFifoInit(nmesa))
return GL_FALSE;

View File

@@ -99,19 +99,22 @@ typedef struct nouveau_context {
/* The read-only regs */
volatile unsigned char* mmio;
/* The per-channel notifier block */
volatile void *notifier_block;
/* Physical addresses of AGP/VRAM apertures */
uint64_t vram_phys;
uint64_t vram_size;
uint64_t agp_phys;
uint64_t agp_size;
uint64_t gart_phys;
uint64_t gart_size;
/* Channel synchronisation */
nouveau_notifier *syncNotifier;
drm_nouveau_notifier_alloc_t *syncNotifier;
/* ARB_occlusion_query / EXT_timer_query */
GLuint query_object_max;
GLboolean * query_alloc;
nouveau_notifier *queryNotifier;
drm_nouveau_notifier_alloc_t *queryNotifier;
/* Additional hw-specific functions */
nouveau_hw_func hw_func;

View File

@@ -99,13 +99,14 @@ void nouveauWaitForIdle(nouveauContextPtr nmesa)
GLboolean nouveauFifoInit(nouveauContextPtr nmesa)
{
drm_nouveau_fifo_alloc_t fifo_init;
int i;
int i, ret;
#ifdef NOUVEAU_RING_DEBUG
return GL_TRUE;
#endif
int ret;
fifo_init.fb_ctxdma_handle = NvDmaFB;
fifo_init.tt_ctxdma_handle = NvDmaTT;
ret=drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_FIFO_ALLOC, &fifo_init, sizeof(fifo_init));
if (ret) {
FATAL("Fifo initialization ioctl failed (returned %d)\n",ret);
@@ -117,12 +118,21 @@ GLboolean nouveauFifoInit(nouveauContextPtr nmesa)
FATAL("Unable to map the fifo (returned %d)\n",ret);
return GL_FALSE;
}
ret = drmMap(nmesa->driFd, fifo_init.ctrl, fifo_init.ctrl_size, &nmesa->fifo.mmio);
if (ret) {
FATAL("Unable to map the control regs (returned %d)\n",ret);
return GL_FALSE;
}
ret = drmMap(nmesa->driFd, fifo_init.notifier,
fifo_init.notifier_size,
&nmesa->notifier_block);
if (ret) {
FATAL("Unable to map the notifier block (returned %d)\n",ret);
return GL_FALSE;
}
/* Setup our initial FIFO tracking params */
nmesa->fifo.channel = fifo_init.channel;
nmesa->fifo.put_base = fifo_init.put_base;

View File

@@ -7,61 +7,18 @@
GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa,
uint32_t handle, int class)
{
drm_nouveau_object_init_t cto;
drm_nouveau_grobj_alloc_t cto;
int ret;
cto.channel = nmesa->fifo.channel;
cto.handle = handle;
cto.class = class;
ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_OBJECT_INIT, &cto, sizeof(cto));
ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_GROBJ_ALLOC,
&cto, sizeof(cto));
return ret == 0;
}
GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa,
uint32_t handle,
int class,
uint32_t offset,
uint32_t size,
int target,
int access)
{
drm_nouveau_dma_object_init_t dma;
int ret;
dma.channel = nmesa->fifo.channel;
dma.class = class;
dma.handle = handle;
dma.target = target;
dma.access = access;
dma.offset = offset;
dma.size = size;
ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_DMA_OBJECT_INIT,
&dma, sizeof(dma));
return ret == 0;
}
GLboolean nouveauCreateDmaObjectFromMem(nouveauContextPtr nmesa,
uint32_t handle, int class,
nouveau_mem *mem,
int access)
{
uint32_t offset = mem->offset;
int target = mem->type & (NOUVEAU_MEM_FB | NOUVEAU_MEM_AGP);
if (!target)
return GL_FALSE;
if (target & NOUVEAU_MEM_FB)
offset -= nmesa->vram_phys;
else if (target & NOUVEAU_MEM_AGP)
offset -= nmesa->agp_phys;
return nouveauCreateDmaObject(nmesa, handle, class,
offset, mem->size,
target, access);
}
void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, int handle)
{
BEGIN_RING_SIZE(subchannel, 0, 1);
@@ -74,16 +31,6 @@ void nouveauObjectInit(nouveauContextPtr nmesa)
return;
#endif
/* We need to know vram size.. and AGP size (and even if the card is AGP..) */
nouveauCreateDmaObject( nmesa, NvDmaFB, NV_DMA_IN_MEMORY,
0, nmesa->vram_size,
NOUVEAU_MEM_FB,
NOUVEAU_MEM_ACCESS_RW);
nouveauCreateDmaObject( nmesa, NvDmaAGP, NV_DMA_IN_MEMORY,
0, nmesa->agp_size,
NOUVEAU_MEM_AGP,
NOUVEAU_MEM_ACCESS_RW);
nouveauCreateContextObject(nmesa, Nv3D, nmesa->screen->card->class_3d);
if (nmesa->screen->card->type>=NV_10) {
nouveauCreateContextObject(nmesa, NvCtxSurf2D, NV10_CONTEXT_SURFACES_2D);

View File

@@ -14,7 +14,7 @@ enum DMAObjects {
NvMemFormat = 0x80000022,
NvCtxSurf3D = 0x80000023,
NvDmaFB = 0xD0FB0001,
NvDmaAGP = 0xD0AA0001,
NvDmaTT = 0xD0AA0001,
NvSyncNotify = 0xD0000001,
NvQueryNotify = 0xD0000002
};
@@ -31,17 +31,5 @@ extern void nouveauObjectOnSubchannel(nouveauContextPtr nmesa, int subchannel, i
extern GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa,
uint32_t handle, int class);
extern GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa,
uint32_t handle,
int class,
uint32_t offset,
uint32_t size,
int target,
int access);
extern GLboolean nouveauCreateDmaObjectFromMem(nouveauContextPtr nmesa,
uint32_t handle,
int class,
nouveau_mem *mem,
int access);
#endif

View File

@@ -68,7 +68,7 @@ nouveauBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
nouveau_query_object *nq = (nouveau_query_object *)q;
nouveau_notifier_reset(nmesa->queryNotifier, nq->notifier_id);
nouveau_notifier_reset(ctx, nmesa->queryNotifier, nq->notifier_id);
switch (nmesa->screen->card->type) {
case NV_20:
@@ -105,12 +105,13 @@ nouveauUpdateQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
nouveau_query_object *nq = (nouveau_query_object *)q;
int status;
status = nouveau_notifier_status(nmesa->queryNotifier,
status = nouveau_notifier_status(ctx, nmesa->queryNotifier,
nq->notifier_id);
q->Ready = (status == NV_NOTIFY_STATE_STATUS_COMPLETED);
if (q->Ready)
q->Result = nouveau_notifier_return_val(nmesa->queryNotifier,
q->Result = nouveau_notifier_return_val(ctx,
nmesa->queryNotifier,
nq->notifier_id);
}
@@ -120,7 +121,7 @@ nouveauWaitQueryResult(GLcontext *ctx, GLenum target, struct gl_query_object *q)
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
nouveau_query_object *nq = (nouveau_query_object *)q;
nouveau_notifier_wait_status(nmesa->queryNotifier, nq->notifier_id,
nouveau_notifier_wait_status(ctx, nmesa->queryNotifier, nq->notifier_id,
NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
nouveauUpdateQuery(ctx, target, q);
}

View File

@@ -328,7 +328,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc
static const __DRIversion ddx_expected = { 1, 2, 0 };
static const __DRIversion dri_expected = { 4, 0, 0 };
static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 6
#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 7
#error nouveau_drm.h version doesn't match expected version
#endif
dri_interface = interface;

View File

@@ -37,6 +37,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define HAVE_HW_STENCIL_SPANS 0
#define HAVE_HW_STENCIL_PIXELS 0
static char *fake_span[1280*1024*4];
#define HW_CLIPLOOP() \
do { \
int _nc = nmesa->numClipRects; \
@@ -52,6 +54,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
GLuint height = nrb->mesa.Height; \
GLubyte *map = (GLubyte *)(nrb->map ? nrb->map : nrb->mem->map) + \
(nmesa->drawY * nrb->pitch) + (nmesa->drawX * nrb->cpp); \
map = fake_span; \
GLuint p; \
(void) p;
@@ -120,6 +123,6 @@ nouveauSpanSetFunctions(nouveau_renderbuffer *nrb, const GLvisual *vis)
{
if (nrb->mesa._ActualFormat == GL_RGBA8)
nouveauInitPointers_ARGB8888(&nrb->mesa);
else if (nrb->mesa._ActualFormat == GL_RGB5)
else // if (nrb->mesa._ActualFormat == GL_RGB5)
nouveauInitPointers_RGB565(&nrb->mesa);
}

View File

@@ -35,53 +35,51 @@
#include "nouveau_msg.h"
#include "nouveau_sync.h"
nouveau_notifier *
#define NOTIFIER(__v) \
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \
volatile uint32_t *__v = (void*)nmesa->notifier_block + notifier->offset
drm_nouveau_notifier_alloc_t *
nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count)
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
nouveau_notifier *notifier;
drm_nouveau_notifier_alloc_t *notifier;
int ret;
#ifdef NOUVEAU_RING_DEBUG
return NULL;
#endif
notifier = CALLOC_STRUCT(nouveau_notifier_t);
notifier = CALLOC_STRUCT(drm_nouveau_notifier_alloc);
if (!notifier)
return NULL;
notifier->mem = nouveau_mem_alloc(ctx,
NOUVEAU_MEM_FB | NOUVEAU_MEM_MAPPED,
count * NV_NOTIFIER_SIZE,
0);
if (!notifier->mem) {
notifier->channel = nmesa->fifo.channel;
notifier->handle = handle;
notifier->count = count;
ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIER_ALLOC,
notifier, sizeof(*notifier));
if (ret) {
MESSAGE("Failed to create notifier 0x%08x: %d\n", handle, ret);
FREE(notifier);
return NULL;
}
if (!nouveauCreateDmaObjectFromMem(nmesa, handle, NV_DMA_IN_MEMORY,
notifier->mem,
NOUVEAU_MEM_ACCESS_RW)) {
nouveau_mem_free(ctx, notifier->mem);
FREE(notifier);
return NULL;
}
notifier->handle = handle;
return notifier;
}
void
nouveau_notifier_destroy(GLcontext *ctx, nouveau_notifier *notifier)
nouveau_notifier_destroy(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier)
{
/*XXX: free DMA object.. */
nouveau_mem_free(ctx, notifier->mem);
/*XXX: free notifier object.. */
FREE(notifier);
}
void
nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id)
nouveau_notifier_reset(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier,
GLuint id)
{
volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
NOTIFIER(n);
#ifdef NOUVEAU_RING_DEBUG
return;
@@ -95,26 +93,29 @@ nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id)
}
GLuint
nouveau_notifier_status(nouveau_notifier *notifier, GLuint id)
nouveau_notifier_status(GLcontext *ctx, drm_nouveau_notifier_alloc_t *notifier,
GLuint id)
{
volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
NOTIFIER(n);
return n[NV_NOTIFY_STATE/4] >> NV_NOTIFY_STATE_STATUS_SHIFT;
}
GLuint
nouveau_notifier_return_val(nouveau_notifier *notifier, GLuint id)
nouveau_notifier_return_val(GLcontext *ctx,
drm_nouveau_notifier_alloc_t *notifier, GLuint id)
{
volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
NOTIFIER(n);
return n[NV_NOTIFY_RETURN_VALUE/4];
}
GLboolean
nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id,
nouveau_notifier_wait_status(GLcontext *ctx,
drm_nouveau_notifier_alloc_t *notifier, GLuint id,
GLuint status, GLuint timeout)
{
volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
NOTIFIER(n);
unsigned int time = 0;
#ifdef NOUVEAU_RING_DEBUG
@@ -144,13 +145,13 @@ nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id,
}
void
nouveau_notifier_wait_nop(GLcontext *ctx, nouveau_notifier *notifier,
GLuint subc)
nouveau_notifier_wait_nop(GLcontext *ctx,
drm_nouveau_notifier_alloc_t *notifier, GLuint subc)
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
NOTIFIER(n);
GLboolean ret;
nouveau_notifier_reset(notifier, 0);
nouveau_notifier_reset(ctx, notifier, 0);
BEGIN_RING_SIZE(subc, NV_NOTIFY, 1);
OUT_RING (NV_NOTIFY_STYLE_WRITE_ONLY);
@@ -158,7 +159,7 @@ nouveau_notifier_wait_nop(GLcontext *ctx, nouveau_notifier *notifier,
OUT_RING (0);
FIRE_RING();
ret = nouveau_notifier_wait_status(notifier, 0,
ret = nouveau_notifier_wait_status(ctx, notifier, 0,
NV_NOTIFY_STATE_STATUS_COMPLETED,
0 /* no timeout */);
if (ret == GL_FALSE) MESSAGE("wait on notifier failed\n");

View File

@@ -47,21 +47,23 @@
#define NV_NOTIFY 0x00000104
#define NV_NOTIFY_STYLE_WRITE_ONLY 0
typedef struct nouveau_notifier_t {
GLuint handle;
nouveau_mem *mem;
} nouveau_notifier;
extern nouveau_notifier *nouveau_notifier_new(GLcontext *, GLuint handle,
GLuint count);
extern void nouveau_notifier_destroy(GLcontext *, nouveau_notifier *);
extern void nouveau_notifier_reset(nouveau_notifier *, GLuint id);
extern GLuint nouveau_notifier_status(nouveau_notifier *, GLuint id);
extern GLuint nouveau_notifier_return_val(nouveau_notifier *, GLuint id);
extern GLboolean nouveau_notifier_wait_status(nouveau_notifier *r, GLuint id,
GLuint status, GLuint timeout);
extern void nouveau_notifier_wait_nop(GLcontext *ctx,
nouveau_notifier *, GLuint subc);
extern drm_nouveau_notifier_alloc_t *
nouveau_notifier_new(GLcontext *, GLuint handle, GLuint count);
extern void
nouveau_notifier_destroy(GLcontext *, drm_nouveau_notifier_alloc_t *);
extern void
nouveau_notifier_reset(GLcontext *, drm_nouveau_notifier_alloc_t *, GLuint id);
extern GLuint
nouveau_notifier_status(GLcontext *, drm_nouveau_notifier_alloc_t *, GLuint id);
extern GLuint
nouveau_notifier_return_val(GLcontext *, drm_nouveau_notifier_alloc_t *,
GLuint id);
extern GLboolean
nouveau_notifier_wait_status(GLcontext *, drm_nouveau_notifier_alloc_t *,
GLuint id, GLuint status, GLuint timeout);
extern void
nouveau_notifier_wait_nop(GLcontext *ctx, drm_nouveau_notifier_alloc_t *,
GLuint subc);
extern GLboolean nouveauSyncInitFuncs(GLcontext *ctx);
#endif

View File

@@ -808,7 +808,7 @@ static GLboolean nv30InitCard(nouveauContextPtr nmesa)
BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT1, 3);
OUT_RING(NvDmaFB);
OUT_RING(NvDmaAGP);
OUT_RING(NvDmaTT);
OUT_RING(NvDmaFB);
BEGIN_RING_SIZE(NvSub3D, NV30_TCL_PRIMITIVE_3D_SET_OBJECT8, 1);
OUT_RING(NvDmaFB);