1
2 #ifndef __NV50_WINSYS_H__
3 #define __NV50_WINSYS_H__
4
5 #include <stdint.h>
6 #include <unistd.h>
7
8 #include "pipe/p_defines.h"
9
10 #include "nouveau_winsys.h"
11 #include "nouveau_buffer.h"
12
13
14 #ifndef NV04_PFIFO_MAX_PACKET_LEN
15 #define NV04_PFIFO_MAX_PACKET_LEN 2047
16 #endif
17
18
19 static inline void
nv50_add_bufctx_resident_bo(struct nouveau_bufctx * bufctx,int bin,unsigned flags,struct nouveau_bo * bo)20 nv50_add_bufctx_resident_bo(struct nouveau_bufctx *bufctx, int bin,
21 unsigned flags, struct nouveau_bo *bo)
22 {
23 nouveau_bufctx_refn(bufctx, bin, bo, flags)->priv = NULL;
24 }
25
26 static inline void
nv50_add_bufctx_resident(struct nouveau_bufctx * bufctx,int bin,struct nv04_resource * res,unsigned flags)27 nv50_add_bufctx_resident(struct nouveau_bufctx *bufctx, int bin,
28 struct nv04_resource *res, unsigned flags)
29 {
30 struct nouveau_bufref *ref =
31 nouveau_bufctx_refn(bufctx, bin, res->bo, flags | res->domain);
32 ref->priv = res;
33 ref->priv_data = flags;
34 }
35
36 #define BCTX_REFN_bo(ctx, bin, fl, bo) \
37 nv50_add_bufctx_resident_bo(ctx, NV50_BIND_##bin, fl, bo);
38
39 #define BCTX_REFN(bctx, bin, res, acc) \
40 nv50_add_bufctx_resident(bctx, NV50_BIND_##bin, res, NOUVEAU_BO_##acc)
41
42 #define SUBC_3D(m) 3, (m)
43 #define NV50_3D(n) SUBC_3D(NV50_3D_##n)
44 #define NV84_3D(n) SUBC_3D(NV84_3D_##n)
45 #define NVA0_3D(n) SUBC_3D(NVA0_3D_##n)
46
47 #define SUBC_2D(m) 4, (m)
48 #define NV50_2D(n) SUBC_2D(NV50_2D_##n)
49
50 #define SUBC_M2MF(m) 5, (m)
51 #define NV50_M2MF(n) SUBC_M2MF(NV50_M2MF_##n)
52
53 #define SUBC_CP(m) 6, (m)
54 #define NV50_CP(n) SUBC_CP(NV50_COMPUTE_##n)
55
56
57 static inline uint32_t
NV50_FIFO_PKHDR(int subc,int mthd,unsigned size)58 NV50_FIFO_PKHDR(int subc, int mthd, unsigned size)
59 {
60 return 0x00000000 | (size << 18) | (subc << 13) | mthd;
61 }
62
63 static inline uint32_t
NV50_FIFO_PKHDR_NI(int subc,int mthd,unsigned size)64 NV50_FIFO_PKHDR_NI(int subc, int mthd, unsigned size)
65 {
66 return 0x40000000 | (size << 18) | (subc << 13) | mthd;
67 }
68
69 static inline uint32_t
NV50_FIFO_PKHDR_L(int subc,int mthd)70 NV50_FIFO_PKHDR_L(int subc, int mthd)
71 {
72 return 0x00030000 | (subc << 13) | mthd;
73 }
74
75
76 static inline uint32_t
nouveau_bo_memtype(const struct nouveau_bo * bo)77 nouveau_bo_memtype(const struct nouveau_bo *bo)
78 {
79 return bo->config.nv50.memtype;
80 }
81
82
83 static inline void
PUSH_DATAh(struct nouveau_pushbuf * push,uint64_t data)84 PUSH_DATAh(struct nouveau_pushbuf *push, uint64_t data)
85 {
86 *push->cur++ = (uint32_t)(data >> 32);
87 }
88
89 /* long, non-incremental, nv50-only */
90 static inline void
BEGIN_NL50(struct nouveau_pushbuf * push,int subc,int mthd,uint32_t size)91 BEGIN_NL50(struct nouveau_pushbuf *push, int subc, int mthd, uint32_t size)
92 {
93 #ifndef NV50_PUSH_EXPLICIT_SPACE_CHECKING
94 PUSH_SPACE(push, 2);
95 #endif
96 PUSH_DATA (push, NV50_FIFO_PKHDR_L(subc, mthd));
97 PUSH_DATA (push, size);
98 }
99
100 #endif /* __NV50_WINSYS_H__ */
101