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