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