1 #ifndef __NV30_WINSYS_H__
2 #define __NV30_WINSYS_H__
3
4 #include <string.h>
5 #include "nouveau_winsys.h"
6 #include "nouveau_context.h"
7 #include "nouveau_buffer.h"
8 #include "nv30_context.h"
9
10 /*XXX: rnn */
11 #define NV40_3D_VTXTEX_OFFSET(i) (0x0900 + ((i) * 0x20)) // 401e80
12 #define NV40_3D_VTXTEX_FORMAT(i) (0x0904 + ((i) * 0x20)) // 401e90
13 #define NV40_3D_VTXTEX_WRAP(i) (0x0908 + ((i) * 0x20)) // 401ea0
14 #define NV40_3D_VTXTEX_ENABLE(i) (0x090c + ((i) * 0x20)) // 401eb0
15 #define NV40_3D_VTXTEX_SWZ(i) (0x0910 + ((i) * 0x20)) // 401ec0
16 #define NV40_3D_VTXTEX_FILTER(i) (0x0914 + ((i) * 0x20)) // 401ed0
17 #define NV40_3D_VTXTEX_SIZE(i) (0x0918 + ((i) * 0x20)) // 401ee0
18 #define NV40_3D_VTXTEX_BCOL(i) (0x091c + ((i) * 0x20)) // 401ef0
19 #define NV30_3D_VTX_CACHE_INVALIDATE_1710 0x1710
20 #define NV30_3D_R1718 0x1718
21 #define NV40_3D_PRIM_RESTART_ENABLE 0x1dac
22 #define NV40_3D_PRIM_RESTART_INDEX 0x1db0
23
24 static inline void
PUSH_RELOC(struct nouveau_pushbuf * push,struct nouveau_bo * bo,uint32_t offset,uint32_t flags,uint32_t vor,uint32_t tor)25 PUSH_RELOC(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t offset,
26 uint32_t flags, uint32_t vor, uint32_t tor)
27 {
28 nouveau_pushbuf_reloc(push, bo, offset, flags, vor, tor);
29 }
30
31 static inline struct nouveau_bufctx *
bufctx(struct nouveau_pushbuf * push)32 bufctx(struct nouveau_pushbuf *push)
33 {
34 struct nouveau_pushbuf_priv *p = push->user_priv;
35 return nv30_context(&p->context->pipe)->bufctx;
36 }
37
38 static inline void
PUSH_RESET(struct nouveau_pushbuf * push,int bin)39 PUSH_RESET(struct nouveau_pushbuf *push, int bin)
40 {
41 nouveau_bufctx_reset(bufctx(push), bin);
42 }
43
44 static inline void
PUSH_MTHDl(struct nouveau_pushbuf * push,int subc,int mthd,int bin,struct nouveau_bo * bo,uint32_t offset,uint32_t access)45 PUSH_MTHDl(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
46 struct nouveau_bo *bo, uint32_t offset, uint32_t access)
47 {
48 nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
49 bo, offset, access | NOUVEAU_BO_LOW, 0, 0)->priv = NULL;
50 PUSH_DATA(push, bo->offset + offset);
51 }
52
53 static inline void
PUSH_MTHDo(struct nouveau_pushbuf * push,int subc,int mthd,int bin,struct nouveau_bo * bo,uint32_t access,uint32_t vor,uint32_t tor)54 PUSH_MTHDo(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
55 struct nouveau_bo *bo, uint32_t access, uint32_t vor, uint32_t tor)
56 {
57 nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
58 bo, 0, access | NOUVEAU_BO_OR, vor, tor)->priv = NULL;
59 if (bo->flags & NOUVEAU_BO_VRAM)
60 PUSH_DATA(push, vor);
61 else
62 PUSH_DATA(push, tor);
63 }
64
65 static inline void
PUSH_MTHDs(struct nouveau_pushbuf * push,int subc,int mthd,int bin,struct nouveau_bo * bo,uint32_t data,uint32_t access,uint32_t vor,uint32_t tor)66 PUSH_MTHDs(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
67 struct nouveau_bo *bo, uint32_t data, uint32_t access,
68 uint32_t vor, uint32_t tor)
69 {
70 nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
71 bo, data, access | NOUVEAU_BO_OR, vor, tor)->priv = NULL;
72 if (bo->flags & NOUVEAU_BO_VRAM)
73 PUSH_DATA(push, data | vor);
74 else
75 PUSH_DATA(push, data | tor);
76 }
77
78 static inline struct nouveau_bufref *
PUSH_MTHD(struct nouveau_pushbuf * push,int subc,int mthd,int bin,struct nouveau_bo * bo,uint32_t data,uint32_t access,uint32_t vor,uint32_t tor)79 PUSH_MTHD(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
80 struct nouveau_bo *bo, uint32_t data, uint32_t access,
81 uint32_t vor, uint32_t tor)
82 {
83 struct nouveau_bufref *bref =
84 nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
85 bo, data, access | NOUVEAU_BO_OR, vor, tor);
86 if (access & NOUVEAU_BO_LOW)
87 data += bo->offset;
88 if (bo->flags & NOUVEAU_BO_VRAM)
89 data |= vor;
90 else
91 data |= tor;
92 PUSH_DATA(push, data);
93 bref->priv = NULL;
94 return bref;
95 }
96
97 static inline void
PUSH_RESRC(struct nouveau_pushbuf * push,int subc,int mthd,int bin,struct nv04_resource * r,uint32_t data,uint32_t access,uint32_t vor,uint32_t tor)98 PUSH_RESRC(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
99 struct nv04_resource *r, uint32_t data, uint32_t access,
100 uint32_t vor, uint32_t tor)
101 {
102 PUSH_MTHD(push, subc, mthd, bin, r->bo, r->offset + data,
103 r->domain | access, vor, tor)->priv = r;
104 }
105
106 /* subchannel assignment
107 *
108 * 0: <1.0.0 - used by kernel for m2mf
109 * 1.0.0 - used by kernel for nvsw
110 *
111 * 1: <1.0.0 - used by kernel for nvsw
112 * 1.0.0 - free for userspace
113 *
114 * 2-7: free for userspace on all kernel versions
115 */
116
117 #define SUBC_M2MF(mthd) 2, (mthd)
118 #define NV03_M2MF(mthd) SUBC_M2MF(NV03_M2MF_##mthd)
119
120 #define SUBC_SF2D(mthd) 3, (mthd)
121 #define NV04_SF2D(mthd) SUBC_SF2D(NV04_SURFACE_2D_##mthd)
122
123 #define SUBC_SSWZ(mthd) 4, (mthd)
124 #define NV04_SSWZ(mthd) SUBC_SSWZ(NV04_SURFACE_SWZ_##mthd)
125
126 #define SUBC_SIFM(mthd) 5, (mthd)
127 #define NV03_SIFM(mthd) SUBC_SIFM(NV03_SIFM_##mthd)
128 #define NV05_SIFM(mthd) SUBC_SIFM(NV05_SIFM_##mthd)
129
130 #define SUBC_3D(mthd) 7, (mthd)
131 #define NV30_3D(mthd) SUBC_3D(NV30_3D_##mthd)
132 #define NV40_3D(mthd) SUBC_3D(NV40_3D_##mthd)
133
134 #define NV01_SUBC(subc, mthd) SUBC_##subc((NV01_SUBCHAN_##mthd))
135 #define NV11_SUBC(subc, mthd) SUBC_##subc((NV11_SUBCHAN_##mthd))
136
137 #define NV04_GRAPH(subc, mthd) SUBC_##subc((NV04_GRAPH_##mthd))
138
139 #endif
140