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