2 #ifndef __NVC0_WINSYS_H__
3 #define __NVC0_WINSYS_H__
7 #include "pipe/p_defines.h"
9 #include "nouveau/nouveau_bo.h"
10 #include "nouveau/nouveau_channel.h"
11 #include "nouveau/nouveau_grobj.h"
12 #include "nouveau/nouveau_device.h"
13 #include "nouveau/nouveau_resource.h"
14 #include "nouveau/nouveau_reloc.h"
16 #include "nvc0_resource.h" /* OUT_RESRC */
18 #ifndef NV04_PFIFO_MAX_PACKET_LEN
19 #define NV04_PFIFO_MAX_PACKET_LEN 2047
22 #define NVC0_SUBCH_3D 1
23 #define NVC0_SUBCH_2D 2
24 #define NVC0_SUBCH_MF 3
26 #define NVC0_MF_(n) NVC0_M2MF_##n
28 #define RING_3D(n) ((NVC0_SUBCH_3D << 13) | (NVC0_3D_##n >> 2))
29 #define RING_2D(n) ((NVC0_SUBCH_2D << 13) | (NVC0_2D_##n >> 2))
30 #define RING_MF(n) ((NVC0_SUBCH_MF << 13) | (NVC0_MF_(n) >> 2))
32 #define RING_3D_(m) ((NVC0_SUBCH_3D << 13) | ((m) >> 2))
33 #define RING_2D_(m) ((NVC0_SUBCH_2D << 13) | ((m) >> 2))
34 #define RING_MF_(m) ((NVC0_SUBCH_MF << 13) | ((m) >> 2))
36 #define RING_GR(gr, m) (((gr)->subc << 13) | ((m) >> 2))
38 int nouveau_pushbuf_flush(struct nouveau_channel
*, unsigned min
);
40 static inline uint32_t
41 nouveau_bo_tile_layout(struct nouveau_bo
*bo
)
43 return bo
->tile_flags
& NOUVEAU_BO_TILE_LAYOUT_MASK
;
47 WAIT_RING(struct nouveau_channel
*chan
, unsigned size
)
49 if (chan
->cur
+ size
> chan
->end
)
50 nouveau_pushbuf_flush(chan
, size
);
54 OUT_RING(struct nouveau_channel
*chan
, uint32_t data
)
56 *(chan
->cur
++) = (data
);
59 /* incremental methods */
61 BEGIN_RING(struct nouveau_channel
*chan
, uint32_t mthd
, unsigned size
)
63 WAIT_RING(chan
, size
+ 1);
64 OUT_RING (chan
, (0x2 << 28) | (size
<< 16) | mthd
);
69 BEGIN_RING_NI(struct nouveau_channel
*chan
, uint32_t mthd
, unsigned size
)
71 WAIT_RING(chan
, size
+ 1);
72 OUT_RING (chan
, (0x6 << 28) | (size
<< 16) | mthd
);
77 BEGIN_RING_1I(struct nouveau_channel
*chan
, uint32_t mthd
, unsigned size
)
79 WAIT_RING(chan
, size
+ 1);
80 OUT_RING (chan
, (0xa << 28) | (size
<< 16) | mthd
);
85 IMMED_RING(struct nouveau_channel
*chan
, uint32_t mthd
, unsigned data
)
88 OUT_RING (chan
, (0x8 << 28) | (data
<< 16) | mthd
);
92 nouveau_pushbuf_marker_emit(struct nouveau_channel
*chan
,
93 unsigned wait_dwords
, unsigned wait_relocs
);
95 nouveau_pushbuf_emit_reloc(struct nouveau_channel
*, void *ptr
,
96 struct nouveau_bo
*, uint32_t data
, uint32_t data2
,
97 uint32_t flags
, uint32_t vor
, uint32_t tor
);
99 nouveau_pushbuf_submit(struct nouveau_channel
*chan
, struct nouveau_bo
*bo
,
100 unsigned offset
, unsigned length
);
103 MARK_RING(struct nouveau_channel
*chan
, unsigned dwords
, unsigned relocs
)
105 return nouveau_pushbuf_marker_emit(chan
, dwords
, relocs
);
109 OUT_RINGf(struct nouveau_channel
*chan
, float data
)
111 union { uint32_t i
; float f
; } u
;
116 static INLINE
unsigned
117 AVAIL_RING(struct nouveau_channel
*chan
)
119 return chan
->end
- chan
->cur
;
123 OUT_RINGp(struct nouveau_channel
*chan
, const void *data
, unsigned size
)
125 memcpy(chan
->cur
, data
, size
* 4);
130 OUT_RELOC(struct nouveau_channel
*chan
, struct nouveau_bo
*bo
,
131 unsigned data
, unsigned flags
, unsigned vor
, unsigned tor
)
133 return nouveau_pushbuf_emit_reloc(chan
, chan
->cur
++, bo
,
134 data
, 0, flags
, vor
, tor
);
138 OUT_RELOCl(struct nouveau_channel
*chan
, struct nouveau_bo
*bo
,
139 unsigned delta
, unsigned flags
)
141 return OUT_RELOC(chan
, bo
, delta
, flags
| NOUVEAU_BO_LOW
, 0, 0);
145 OUT_RELOCh(struct nouveau_channel
*chan
, struct nouveau_bo
*bo
,
146 unsigned delta
, unsigned flags
)
148 return OUT_RELOC(chan
, bo
, delta
, flags
| NOUVEAU_BO_HIGH
, 0, 0);
152 OUT_RESRCh(struct nouveau_channel
*chan
, struct nvc0_resource
*res
,
153 unsigned delta
, unsigned flags
)
155 return OUT_RELOCh(chan
, res
->bo
, res
->offset
+ delta
, res
->domain
| flags
);
159 OUT_RESRCl(struct nouveau_channel
*chan
, struct nvc0_resource
*res
,
160 unsigned delta
, unsigned flags
)
162 return OUT_RELOCl(chan
, res
->bo
, res
->offset
+ delta
, res
->domain
| flags
);
166 FIRE_RING(struct nouveau_channel
*chan
)
168 nouveau_pushbuf_flush(chan
, 0);
172 BIND_RING(struct nouveau_channel
*chan
, struct nouveau_grobj
*gr
, unsigned s
)
174 struct nouveau_subchannel
*subc
= &gr
->channel
->subc
[s
];
178 assert(subc
->gr
->bound
!= NOUVEAU_GROBJ_BOUND_EXPLICIT
);
179 subc
->gr
->bound
= NOUVEAU_GROBJ_UNBOUND
;
183 subc
->gr
->bound
= NOUVEAU_GROBJ_BOUND_EXPLICIT
;
185 BEGIN_RING(chan
, RING_GR(gr
, 0x0000), 1);
186 OUT_RING (chan
, gr
->grclass
);