1 #include "vblank.h" /* for DO_USLEEP */
3 #include "nouveau_context.h"
4 #include "nouveau_buffers.h"
5 #include "nouveau_object.h"
6 #include "nouveau_fifo.h"
7 #include "nouveau_reg.h"
8 #include "nouveau_msg.h"
9 #include "nouveau_sync.h"
12 nouveau_notifier_new(GLcontext
*ctx
, GLuint handle
)
14 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
15 nouveau_notifier
*notifier
;
17 notifier
= CALLOC_STRUCT(nouveau_notifier_t
);
21 notifier
->mem
= nouveau_mem_alloc(ctx
, NOUVEAU_MEM_FB
, 32, 0);
27 if (!nouveauCreateDmaObject(nmesa
, handle
, notifier
->mem
->offset
,
29 0 /* NV_DMA_TARGET_FB */,
30 0 /* NV_DMA_ACCESS_RW */)) {
31 nouveau_mem_free(ctx
, notifier
->mem
);
36 notifier
->handle
= handle
;
41 nouveau_notifier_destroy(GLcontext
*ctx
, nouveau_notifier
*notifier
)
43 /*XXX: free DMA object.. */
44 nouveau_mem_free(ctx
, notifier
->mem
);
49 nouveau_notifier_reset(nouveau_notifier
*notifier
)
51 volatile GLuint
*n
= notifier
->mem
->map
;
53 n
[NV_NOTIFY_TIME_0
/4] = 0x00000000;
54 n
[NV_NOTIFY_TIME_1
/4] = 0x00000000;
55 n
[NV_NOTIFY_RETURN_VALUE
/4] = 0x00000000;
56 n
[NV_NOTIFY_STATE
/4] = (NV_NOTIFY_STATE_STATUS_IN_PROCESS
<<
57 NV_NOTIFY_STATE_STATUS_SHIFT
);
61 nouveau_notifier_wait_status(nouveau_notifier
*notifier
, GLuint status
,
64 volatile GLuint
*n
= notifier
->mem
->map
;
65 unsigned int time
= 0;
67 while (time
<= timeout
) {
68 if (n
[NV_NOTIFY_STATE
] & NV_NOTIFY_STATE_ERROR_CODE_MASK
) {
69 MESSAGE("Notifier returned error: 0x%04x\n",
71 NV_NOTIFY_STATE_ERROR_CODE_MASK
);
75 if (((n
[NV_NOTIFY_STATE
] & NV_NOTIFY_STATE_STATUS_MASK
) >>
76 NV_NOTIFY_STATE_STATUS_SHIFT
) == status
)
85 MESSAGE("Notifier timed out\n");
90 nouveau_notifier_wait_nop(GLcontext
*ctx
, nouveau_notifier
*notifier
,
93 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
96 nouveau_notifier_reset(notifier
);
98 BEGIN_RING_SIZE(subc
, NV_NOTIFY
, 1);
99 OUT_RING (NV_NOTIFY_STYLE_WRITE_ONLY
);
100 BEGIN_RING_SIZE(subc
, NV_NOP
, 1);
103 ret
= nouveau_notifier_wait_status(notifier
,
104 NV_NOTIFY_STATE_STATUS_COMPLETED
,
106 if (ret
) MESSAGE("wait on notifier failed\n");
109 GLboolean
nouveauSyncInitFuncs(GLcontext
*ctx
)
111 nouveauContextPtr nmesa
= NOUVEAU_CONTEXT(ctx
);
113 nmesa
->syncNotifier
= nouveau_notifier_new(ctx
, NvSyncNotify
);
114 if (!nmesa
->syncNotifier
) {
115 MESSAGE("Failed to create channel sync notifier\n");
119 /* 0x180 is SET_DMA_NOTIFY, should be correct for all supported 3D
122 BEGIN_RING_CACHE(NvSub3D
, 0x180, 1);
123 OUT_RING_CACHE (NvSyncNotify
);