summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/nouveau/nouveau_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/nouveau/nouveau_sync.c')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_sync.c84
1 files changed, 44 insertions, 40 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
index 30e6696269..2ca038f4f8 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
@@ -28,60 +28,60 @@
#include "vblank.h" /* for DO_USLEEP */
#include "nouveau_context.h"
-#include "nouveau_buffers.h"
-#include "nouveau_object.h"
#include "nouveau_fifo.h"
-#include "nouveau_reg.h"
+#include "nouveau_mem.h"
#include "nouveau_msg.h"
+#include "nouveau_object.h"
+#include "nouveau_reg.h"
#include "nouveau_sync.h"
-nouveau_notifier *
+#define NOTIFIER(__v) \
+ nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx); \
+ volatile uint32_t *__v = (void*)nmesa->fifo.notifier_block + \
+ notifier->offset
+
+struct drm_nouveau_notifierobj_alloc *
nouveau_notifier_new(GLcontext *ctx, GLuint handle, GLuint count)
{
nouveauContextPtr nmesa = NOUVEAU_CONTEXT(ctx);
- nouveau_notifier *notifier;
+ struct drm_nouveau_notifierobj_alloc *notifier;
+ int ret;
#ifdef NOUVEAU_RING_DEBUG
return NULL;
#endif
-
- notifier = CALLOC_STRUCT(nouveau_notifier_t);
+ notifier = CALLOC_STRUCT(drm_nouveau_notifierobj_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.drm.channel;
+ notifier->handle = handle;
+ notifier->count = count;
+ ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_NOTIFIEROBJ_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,
+ struct drm_nouveau_notifierobj_alloc *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,
+ struct drm_nouveau_notifierobj_alloc *notifier,
+ GLuint id)
{
- volatile GLuint *n = notifier->mem->map + (id * NV_NOTIFIER_SIZE);
+ NOTIFIER(n);
#ifdef NOUVEAU_RING_DEBUG
return;
@@ -95,26 +95,31 @@ nouveau_notifier_reset(nouveau_notifier *notifier, GLuint id)
}
GLuint
-nouveau_notifier_status(nouveau_notifier *notifier, GLuint id)
+nouveau_notifier_status(GLcontext *ctx,
+ struct drm_nouveau_notifierobj_alloc *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,
+ struct drm_nouveau_notifierobj_alloc *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,
- GLuint status, GLuint timeout)
+nouveau_notifier_wait_status(GLcontext *ctx,
+ struct drm_nouveau_notifierobj_alloc *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 +149,14 @@ 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,
+ struct drm_nouveau_notifierobj_alloc *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 +164,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");
@@ -183,11 +189,9 @@ GLboolean nouveauSyncInitFuncs(GLcontext *ctx)
*/
BEGIN_RING_CACHE(NvSub3D, 0x180, 1);
OUT_RING_CACHE (NvSyncNotify);
-#ifdef ALLOW_MULTI_SUBCHANNEL
BEGIN_RING_SIZE(NvSubMemFormat,
NV_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
OUT_RING (NvSyncNotify);
-#endif
return GL_TRUE;
}