Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / mesa / drivers / dri / nouveau_winsys / nouveau_local.h
1 #ifndef __NOUVEAU_LOCAL_H__
2 #define __NOUVEAU_LOCAL_H__
3
4 #include <stdio.h>
5
6 /* Debug output */
7 #define NOUVEAU_MSG(fmt, args...) do { \
8 fprintf(stdout, "nouveau: "fmt, ##args); \
9 fflush(stdout); \
10 } while(0)
11
12 #define NOUVEAU_ERR(fmt, args...) do { \
13 fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); \
14 fflush(stderr); \
15 } while(0)
16
17 #define NOUVEAU_TIME_MSEC() 0
18
19 /* User FIFO control */
20 //#define NOUVEAU_DMA_TRACE
21 //#define NOUVEAU_DMA_DEBUG
22 //#define NOUVEAU_DMA_DUMP_POSTRELOC_PUSHBUF
23 #define NOUVEAU_DMA_BARRIER
24 #define NOUVEAU_DMA_TIMEOUT 2000
25
26 /* Push buffer access macros */
27 #define OUT_RING(data) do { \
28 (*nv->channel->pushbuf->cur++) = (data); \
29 } while(0)
30
31 #define OUT_RINGp(src,size) do { \
32 memcpy(nv->channel->pushbuf->cur, (src), (size)<<2); \
33 nv->channel->pushbuf->cur += (size); \
34 } while(0)
35
36 #define OUT_RINGf(data) do { \
37 union { float v; uint32_t u; } c; \
38 c.v = (data); \
39 OUT_RING(c.u); \
40 } while(0)
41
42 #define FIRE_RING() do { \
43 nouveau_pushbuf_flush(nv->channel, 0); \
44 } while(0)
45
46 #define BEGIN_RING_GR(obj,mthd,size) do { \
47 if (nv->channel->pushbuf->remaining < ((size) + 1)) \
48 nouveau_pushbuf_flush(nv->channel, ((size) + 1)); \
49 OUT_RING(((obj)->subc << 13) | ((size) << 18) | (mthd)); \
50 nv->channel->pushbuf->remaining -= ((size) + 1); \
51 } while(0)
52
53 #define BEGIN_RING(obj,mthd,size) do { \
54 BEGIN_RING_GR(nv->obj, (mthd), (size)); \
55 } while(0)
56
57 #define BIND_RING(o,s) do { \
58 nv->o->subc = (s); \
59 BEGIN_RING(o, 0x0000, 1); \
60 OUT_RING (nv->o->handle); \
61 } while(0)
62
63 #define OUT_RELOC(buf,data,flags,vor,tor) do { \
64 nouveau_pipe_emit_reloc(nv->channel, nv->channel->pushbuf->cur++, \
65 buf, (data), (flags), (vor), (tor)); \
66 } while(0)
67
68 /* Raw data + flags depending on FB/TT buffer */
69 #define OUT_RELOCd(bo,data,flags,vor,tor) do { \
70 OUT_RELOC((bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor)); \
71 } while(0)
72
73 /* FB/TT object handle */
74 #define OUT_RELOCo(bo,flags) do { \
75 OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR, \
76 nv->channel->vram->handle, nv->channel->gart->handle); \
77 } while(0)
78
79 /* Low 32-bits of offset */
80 #define OUT_RELOCl(bo,delta,flags) do { \
81 OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0); \
82 } while(0)
83
84 /* High 32-bits of offset */
85 #define OUT_RELOCh(bo,delta,flags) do { \
86 OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0); \
87 } while(0)
88
89 #endif