1 #ifndef __NV30_WINSYS_H__
2 #define __NV30_WINSYS_H__
5 #include "nouveau_winsys.h"
6 #include "nouveau_buffer.h"
9 #define NV40_3D_VTXTEX_OFFSET(i) (0x0900 + ((i) * 0x20)) // 401e80
10 #define NV40_3D_VTXTEX_FORMAT(i) (0x0904 + ((i) * 0x20)) // 401e90
11 #define NV40_3D_VTXTEX_WRAP(i) (0x0908 + ((i) * 0x20)) // 401ea0
12 #define NV40_3D_VTXTEX_ENABLE(i) (0x090c + ((i) * 0x20)) // 401eb0
13 #define NV40_3D_VTXTEX_SWZ(i) (0x0910 + ((i) * 0x20)) // 401ec0
14 #define NV40_3D_VTXTEX_FILTER(i) (0x0914 + ((i) * 0x20)) // 401ed0
15 #define NV40_3D_VTXTEX_SIZE(i) (0x0918 + ((i) * 0x20)) // 401ee0
16 #define NV40_3D_VTXTEX_BCOL(i) (0x091c + ((i) * 0x20)) // 401ef0
17 #define NV30_3D_VTX_CACHE_INVALIDATE_1710 0x1710
18 #define NV30_3D_R1718 0x1718
19 #define NV40_3D_PRIM_RESTART_ENABLE 0x1dac
20 #define NV40_3D_PRIM_RESTART_INDEX 0x1db0
23 PUSH_RELOC(struct nouveau_pushbuf
*push
, struct nouveau_bo
*bo
, uint32_t offset
,
24 uint32_t flags
, uint32_t vor
, uint32_t tor
)
26 nouveau_pushbuf_reloc(push
, bo
, offset
, flags
, vor
, tor
);
29 static inline struct nouveau_bufctx
*
30 bufctx(struct nouveau_pushbuf
*push
)
32 struct nouveau_bufctx
**pctx
= push
->user_priv
;
37 PUSH_RESET(struct nouveau_pushbuf
*push
, int bin
)
39 nouveau_bufctx_reset(bufctx(push
), bin
);
43 PUSH_REFN(struct nouveau_pushbuf
*push
, int bin
,
44 struct nouveau_bo
*bo
, uint32_t access
)
46 nouveau_bufctx_refn(bufctx(push
), bin
, bo
, access
);
50 PUSH_MTHDl(struct nouveau_pushbuf
*push
, int subc
, int mthd
, int bin
,
51 struct nouveau_bo
*bo
, uint32_t offset
, uint32_t access
)
53 nouveau_bufctx_mthd(bufctx(push
), bin
, (1 << 18) | (subc
<< 13) | mthd
,
54 bo
, offset
, access
| NOUVEAU_BO_LOW
, 0, 0)->priv
= NULL
;
55 PUSH_DATA(push
, bo
->offset
+ offset
);
59 PUSH_MTHDo(struct nouveau_pushbuf
*push
, int subc
, int mthd
, int bin
,
60 struct nouveau_bo
*bo
, uint32_t access
, uint32_t vor
, uint32_t tor
)
62 nouveau_bufctx_mthd(bufctx(push
), bin
, (1 << 18) | (subc
<< 13) | mthd
,
63 bo
, 0, access
| NOUVEAU_BO_OR
, vor
, tor
)->priv
= NULL
;
64 if (bo
->flags
& NOUVEAU_BO_VRAM
)
71 PUSH_MTHDs(struct nouveau_pushbuf
*push
, int subc
, int mthd
, int bin
,
72 struct nouveau_bo
*bo
, uint32_t data
, uint32_t access
,
73 uint32_t vor
, uint32_t tor
)
75 nouveau_bufctx_mthd(bufctx(push
), bin
, (1 << 18) | (subc
<< 13) | mthd
,
76 bo
, data
, access
| NOUVEAU_BO_OR
, vor
, tor
)->priv
= NULL
;
77 if (bo
->flags
& NOUVEAU_BO_VRAM
)
78 PUSH_DATA(push
, data
| vor
);
80 PUSH_DATA(push
, data
| tor
);
83 static inline struct nouveau_bufref
*
84 PUSH_MTHD(struct nouveau_pushbuf
*push
, int subc
, int mthd
, int bin
,
85 struct nouveau_bo
*bo
, uint32_t data
, uint32_t access
,
86 uint32_t vor
, uint32_t tor
)
88 struct nouveau_bufref
*bref
=
89 nouveau_bufctx_mthd(bufctx(push
), bin
, (1 << 18) | (subc
<< 13) | mthd
,
90 bo
, data
, access
| NOUVEAU_BO_OR
, vor
, tor
);
91 if (access
& NOUVEAU_BO_LOW
)
93 if (bo
->flags
& NOUVEAU_BO_VRAM
)
97 PUSH_DATA(push
, data
);
103 PUSH_RESRC(struct nouveau_pushbuf
*push
, int subc
, int mthd
, int bin
,
104 struct nv04_resource
*r
, uint32_t data
, uint32_t access
,
105 uint32_t vor
, uint32_t tor
)
107 PUSH_MTHD(push
, subc
, mthd
, bin
, r
->bo
, r
->offset
+ data
,
108 r
->domain
| access
, vor
, tor
)->priv
= r
;
112 BEGIN_NV04(struct nouveau_pushbuf
*push
, int subc
, int mthd
, int size
)
114 PUSH_SPACE(push
, size
+ 1);
115 PUSH_DATA (push
, 0x00000000 | (size
<< 18) | (subc
<< 13) | mthd
);
119 BEGIN_NI04(struct nouveau_pushbuf
*push
, int subc
, int mthd
, int size
)
121 PUSH_SPACE(push
, size
+ 1);
122 PUSH_DATA (push
, 0x40000000 | (size
<< 18) | (subc
<< 13) | mthd
);
125 /* subchannel assignment
127 * 0: <1.0.0 - used by kernel for m2mf
128 * 1.0.0 - used by kernel for nvsw
130 * 1: <1.0.0 - used by kernel for nvsw
131 * 1.0.0 - free for userspace
133 * 2-7: free for userspace on all kernel versions
136 #define SUBC_M2MF(mthd) 2, (mthd)
137 #define NV03_M2MF(mthd) SUBC_M2MF(NV03_M2MF_##mthd)
139 #define SUBC_SF2D(mthd) 3, (mthd)
140 #define NV04_SF2D(mthd) SUBC_SF2D(NV04_SURFACE_2D_##mthd)
142 #define SUBC_SSWZ(mthd) 4, (mthd)
143 #define NV04_SSWZ(mthd) SUBC_SSWZ(NV04_SURFACE_SWZ_##mthd)
145 #define SUBC_SIFM(mthd) 5, (mthd)
146 #define NV03_SIFM(mthd) SUBC_SIFM(NV03_SIFM_##mthd)
147 #define NV05_SIFM(mthd) SUBC_SIFM(NV05_SIFM_##mthd)
149 #define SUBC_3D(mthd) 7, (mthd)
150 #define NV30_3D(mthd) SUBC_3D(NV30_3D_##mthd)
151 #define NV40_3D(mthd) SUBC_3D(NV40_3D_##mthd)
153 #define NV01_SUBC(subc, mthd) SUBC_##subc((NV01_SUBCHAN_##mthd))
154 #define NV11_SUBC(subc, mthd) SUBC_##subc((NV11_SUBCHAN_##mthd))
156 #define NV04_GRAPH(subc, mthd) SUBC_##subc((NV04_GRAPH_##mthd))