1bf215546Sopenharmony_ci 2bf215546Sopenharmony_ci#ifndef __NVC0_WINSYS_H__ 3bf215546Sopenharmony_ci#define __NVC0_WINSYS_H__ 4bf215546Sopenharmony_ci 5bf215546Sopenharmony_ci#include <stdint.h> 6bf215546Sopenharmony_ci#include <unistd.h> 7bf215546Sopenharmony_ci 8bf215546Sopenharmony_ci#include "pipe/p_defines.h" 9bf215546Sopenharmony_ci 10bf215546Sopenharmony_ci#include "nouveau_winsys.h" 11bf215546Sopenharmony_ci#include "nouveau_buffer.h" 12bf215546Sopenharmony_ci 13bf215546Sopenharmony_ci#ifndef NV04_PFIFO_MAX_PACKET_LEN 14bf215546Sopenharmony_ci#define NV04_PFIFO_MAX_PACKET_LEN 2047 15bf215546Sopenharmony_ci#endif 16bf215546Sopenharmony_ci 17bf215546Sopenharmony_ci 18bf215546Sopenharmony_cistatic inline void 19bf215546Sopenharmony_cinv50_add_bufctx_resident_bo(struct nouveau_bufctx *bufctx, int bin, 20bf215546Sopenharmony_ci unsigned flags, struct nouveau_bo *bo) 21bf215546Sopenharmony_ci{ 22bf215546Sopenharmony_ci nouveau_bufctx_refn(bufctx, bin, bo, flags)->priv = NULL; 23bf215546Sopenharmony_ci} 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_cistatic inline void 26bf215546Sopenharmony_cinvc0_add_resident(struct nouveau_bufctx *bufctx, int bin, 27bf215546Sopenharmony_ci struct nv04_resource *res, unsigned flags) 28bf215546Sopenharmony_ci{ 29bf215546Sopenharmony_ci struct nouveau_bufref *ref = 30bf215546Sopenharmony_ci nouveau_bufctx_refn(bufctx, bin, res->bo, flags | res->domain); 31bf215546Sopenharmony_ci ref->priv = res; 32bf215546Sopenharmony_ci ref->priv_data = flags; 33bf215546Sopenharmony_ci} 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#define BCTX_REFN_bo(ctx, bin, fl, bo) \ 36bf215546Sopenharmony_ci nv50_add_bufctx_resident_bo(ctx, NVC0_BIND_##bin, fl, bo); 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci#define BCTX_REFN(bctx, bin, res, acc) \ 39bf215546Sopenharmony_ci nvc0_add_resident(bctx, NVC0_BIND_##bin, res, NOUVEAU_BO_##acc) 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_cistatic inline void 42bf215546Sopenharmony_ciPUSH_REFN(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t flags) 43bf215546Sopenharmony_ci{ 44bf215546Sopenharmony_ci struct nouveau_pushbuf_refn ref = { bo, flags }; 45bf215546Sopenharmony_ci nouveau_pushbuf_refn(push, &ref, 1); 46bf215546Sopenharmony_ci} 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci#define SUBC_3D(m) 0, (m) 50bf215546Sopenharmony_ci#define NVC0_3D(n) SUBC_3D(NVC0_3D_##n) 51bf215546Sopenharmony_ci#define NVE4_3D(n) SUBC_3D(NVE4_3D_##n) 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci#define SUBC_CP(m) 1, (m) 54bf215546Sopenharmony_ci#define NVC0_CP(n) SUBC_CP(NVC0_COMPUTE_##n) 55bf215546Sopenharmony_ci#define NVE4_CP(n) SUBC_CP(NVE4_COMPUTE_##n) 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci#define SUBC_M2MF(m) 2, (m) 58bf215546Sopenharmony_ci#define SUBC_P2MF(m) 2, (m) 59bf215546Sopenharmony_ci#define NVC0_M2MF(n) SUBC_M2MF(NVC0_M2MF_##n) 60bf215546Sopenharmony_ci#define NVE4_P2MF(n) SUBC_P2MF(NVE4_P2MF_##n) 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci#define SUBC_2D(m) 3, (m) 63bf215546Sopenharmony_ci#define NVC0_2D(n) SUBC_2D(NV50_2D_##n) 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci#define SUBC_COPY(m) 4, (m) 66bf215546Sopenharmony_ci#define NVE4_COPY(n) SUBC_COPY(NVE4_COPY_##n) 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci#define SUBC_SW(m) 7, (m) 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci#define NVC0_3D_SERIALIZE NV50_GRAPH_SERIALIZE 71bf215546Sopenharmony_ci#define NVC0_IB_ENTRY_1_NO_PREFETCH (1 << (31 - 8)) 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_cistatic inline uint32_t 74bf215546Sopenharmony_ciNVC0_FIFO_PKHDR_SQ(int subc, int mthd, unsigned size) 75bf215546Sopenharmony_ci{ 76bf215546Sopenharmony_ci return 0x20000000 | (size << 16) | (subc << 13) | (mthd >> 2); 77bf215546Sopenharmony_ci} 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_cistatic inline uint32_t 80bf215546Sopenharmony_ciNVC0_FIFO_PKHDR_NI(int subc, int mthd, unsigned size) 81bf215546Sopenharmony_ci{ 82bf215546Sopenharmony_ci return 0x60000000 | (size << 16) | (subc << 13) | (mthd >> 2); 83bf215546Sopenharmony_ci} 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_cistatic inline uint32_t 86bf215546Sopenharmony_ciNVC0_FIFO_PKHDR_IL(int subc, int mthd, uint16_t data) 87bf215546Sopenharmony_ci{ 88bf215546Sopenharmony_ci assert(data < 0x2000); 89bf215546Sopenharmony_ci return 0x80000000 | (data << 16) | (subc << 13) | (mthd >> 2); 90bf215546Sopenharmony_ci} 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_cistatic inline uint32_t 93bf215546Sopenharmony_ciNVC0_FIFO_PKHDR_1I(int subc, int mthd, unsigned size) 94bf215546Sopenharmony_ci{ 95bf215546Sopenharmony_ci return 0xa0000000 | (size << 16) | (subc << 13) | (mthd >> 2); 96bf215546Sopenharmony_ci} 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_cistatic inline uint8_t 100bf215546Sopenharmony_cinouveau_bo_memtype(const struct nouveau_bo *bo) 101bf215546Sopenharmony_ci{ 102bf215546Sopenharmony_ci return bo->config.nvc0.memtype; 103bf215546Sopenharmony_ci} 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_ci 106bf215546Sopenharmony_cistatic inline void 107bf215546Sopenharmony_ciPUSH_DATAh(struct nouveau_pushbuf *push, uint64_t data) 108bf215546Sopenharmony_ci{ 109bf215546Sopenharmony_ci *push->cur++ = (uint32_t)(data >> 32); 110bf215546Sopenharmony_ci} 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_cistatic inline void 113bf215546Sopenharmony_ciBEGIN_NVC0(struct nouveau_pushbuf *push, int subc, int mthd, unsigned size) 114bf215546Sopenharmony_ci{ 115bf215546Sopenharmony_ci#ifndef NVC0_PUSH_EXPLICIT_SPACE_CHECKING 116bf215546Sopenharmony_ci PUSH_SPACE(push, size + 1); 117bf215546Sopenharmony_ci#endif 118bf215546Sopenharmony_ci PUSH_DATA (push, NVC0_FIFO_PKHDR_SQ(subc, mthd, size)); 119bf215546Sopenharmony_ci} 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_cistatic inline void 122bf215546Sopenharmony_ciBEGIN_NIC0(struct nouveau_pushbuf *push, int subc, int mthd, unsigned size) 123bf215546Sopenharmony_ci{ 124bf215546Sopenharmony_ci#ifndef NVC0_PUSH_EXPLICIT_SPACE_CHECKING 125bf215546Sopenharmony_ci PUSH_SPACE(push, size + 1); 126bf215546Sopenharmony_ci#endif 127bf215546Sopenharmony_ci PUSH_DATA (push, NVC0_FIFO_PKHDR_NI(subc, mthd, size)); 128bf215546Sopenharmony_ci} 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_cistatic inline void 131bf215546Sopenharmony_ciBEGIN_1IC0(struct nouveau_pushbuf *push, int subc, int mthd, unsigned size) 132bf215546Sopenharmony_ci{ 133bf215546Sopenharmony_ci#ifndef NVC0_PUSH_EXPLICIT_SPACE_CHECKING 134bf215546Sopenharmony_ci PUSH_SPACE(push, size + 1); 135bf215546Sopenharmony_ci#endif 136bf215546Sopenharmony_ci PUSH_DATA (push, NVC0_FIFO_PKHDR_1I(subc, mthd, size)); 137bf215546Sopenharmony_ci} 138bf215546Sopenharmony_ci 139bf215546Sopenharmony_cistatic inline void 140bf215546Sopenharmony_ciIMMED_NVC0(struct nouveau_pushbuf *push, int subc, int mthd, uint16_t data) 141bf215546Sopenharmony_ci{ 142bf215546Sopenharmony_ci#ifndef NVC0_PUSH_EXPLICIT_SPACE_CHECKING 143bf215546Sopenharmony_ci PUSH_SPACE(push, 1); 144bf215546Sopenharmony_ci#endif 145bf215546Sopenharmony_ci PUSH_DATA (push, NVC0_FIFO_PKHDR_IL(subc, mthd, data)); 146bf215546Sopenharmony_ci} 147bf215546Sopenharmony_ci 148bf215546Sopenharmony_ci#endif /* __NVC0_WINSYS_H__ */ 149