summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nouveau/nv30/nv30_winsys.h
blob: 5cee5df60ce964ad9a8d52045671306f5382f9b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef __NV30_WINSYS_H__
#define __NV30_WINSYS_H__

#include <string.h>
#include "nouveau_winsys.h"
#include "nouveau_buffer.h"

/*XXX: rnn */
#define NV40_3D_VTXTEX_OFFSET(i) (0x0900 + ((i) * 0x20)) // 401e80
#define NV40_3D_VTXTEX_FORMAT(i) (0x0904 + ((i) * 0x20)) // 401e90
#define NV40_3D_VTXTEX_WRAP(i)   (0x0908 + ((i) * 0x20)) // 401ea0
#define NV40_3D_VTXTEX_ENABLE(i) (0x090c + ((i) * 0x20)) // 401eb0
#define NV40_3D_VTXTEX_SWZ(i)    (0x0910 + ((i) * 0x20)) // 401ec0
#define NV40_3D_VTXTEX_FILTER(i) (0x0914 + ((i) * 0x20)) // 401ed0
#define NV40_3D_VTXTEX_SIZE(i)   (0x0918 + ((i) * 0x20)) // 401ee0
#define NV40_3D_VTXTEX_BCOL(i)   (0x091c + ((i) * 0x20)) // 401ef0
#define NV30_3D_VTX_CACHE_INVALIDATE_1710 0x1710
#define NV30_3D_R1718 0x1718
#define NV40_3D_PRIM_RESTART_ENABLE 0x1dac
#define NV40_3D_PRIM_RESTART_INDEX  0x1db0

static INLINE void
PUSH_RELOC(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t offset,
      uint32_t flags, uint32_t vor, uint32_t tor)
{
   nouveau_pushbuf_reloc(push, bo, offset, flags, vor, tor);
}

static INLINE struct nouveau_bufctx *
bufctx(struct nouveau_pushbuf *push)
{
   struct nouveau_bufctx **pctx = push->user_priv;
   return *pctx;
}

static INLINE void
PUSH_RESET(struct nouveau_pushbuf *push, int bin)
{
   nouveau_bufctx_reset(bufctx(push), bin);
}

static INLINE void
PUSH_REFN(struct nouveau_pushbuf *push, int bin,
     struct nouveau_bo *bo, uint32_t access)
{
   nouveau_bufctx_refn(bufctx(push), bin, bo, access);
}

static INLINE void
PUSH_MTHDl(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
      struct nouveau_bo *bo, uint32_t offset, uint32_t access)
{
   nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
                       bo, offset, access | NOUVEAU_BO_LOW, 0, 0)->priv = NULL;
   PUSH_DATA(push, bo->offset + offset);
}

static INLINE void
PUSH_MTHDo(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
      struct nouveau_bo *bo, uint32_t access, uint32_t vor, uint32_t tor)
{
   nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
                       bo, 0, access | NOUVEAU_BO_OR, vor, tor)->priv = NULL;
   if (bo->flags & NOUVEAU_BO_VRAM)
      PUSH_DATA(push, vor);
   else
      PUSH_DATA(push, tor);
}

static INLINE void
PUSH_MTHDs(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
      struct nouveau_bo *bo, uint32_t data, uint32_t access,
      uint32_t vor, uint32_t tor)
{
   nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
                       bo, data, access | NOUVEAU_BO_OR, vor, tor)->priv = NULL;
   if (bo->flags & NOUVEAU_BO_VRAM)
      PUSH_DATA(push, data | vor);
   else
      PUSH_DATA(push, data | tor);
}

static INLINE struct nouveau_bufref *
PUSH_MTHD(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
     struct nouveau_bo *bo, uint32_t data, uint32_t access,
     uint32_t vor, uint32_t tor)
{
   struct nouveau_bufref *bref =
   nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
                       bo, data, access | NOUVEAU_BO_OR, vor, tor);
   if (access & NOUVEAU_BO_LOW)
      data += bo->offset;
   if (bo->flags & NOUVEAU_BO_VRAM)
      data |= vor;
   else
      data |= tor;
   PUSH_DATA(push, data);
   bref->priv = NULL;
   return bref;
}

static INLINE void
PUSH_RESRC(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
           struct nv04_resource *r, uint32_t data, uint32_t access,
           uint32_t vor, uint32_t tor)
{
   PUSH_MTHD(push, subc, mthd, bin, r->bo, r->offset + data,
             r->domain | access, vor, tor)->priv = r;
}

static INLINE void
BEGIN_NV04(struct nouveau_pushbuf *push, int subc, int mthd, int size)
{
   PUSH_SPACE(push, size + 1);
   PUSH_DATA (push, 0x00000000 | (size << 18) | (subc << 13) | mthd);
}

static INLINE void
BEGIN_NI04(struct nouveau_pushbuf *push, int subc, int mthd, int size)
{
   PUSH_SPACE(push, size + 1);
   PUSH_DATA (push, 0x40000000 | (size << 18) | (subc << 13) | mthd);
}

/* subchannel assignment
 *
 * 0: <1.0.0 - used by kernel for m2mf
 *     1.0.0 - used by kernel for nvsw
 *
 * 1: <1.0.0 - used by kernel for nvsw
 *     1.0.0 - free for userspace
 *
 * 2-7: free for userspace on all kernel versions
 */

#define SUBC_M2MF(mthd)  2, (mthd)
#define NV03_M2MF(mthd)  SUBC_M2MF(NV03_M2MF_##mthd)

#define SUBC_SF2D(mthd)  3, (mthd)
#define NV04_SF2D(mthd)  SUBC_SF2D(NV04_SURFACE_2D_##mthd)

#define SUBC_SSWZ(mthd)  4, (mthd)
#define NV04_SSWZ(mthd)  SUBC_SSWZ(NV04_SURFACE_SWZ_##mthd)

#define SUBC_SIFM(mthd)  5, (mthd)
#define NV03_SIFM(mthd)  SUBC_SIFM(NV03_SIFM_##mthd)
#define NV05_SIFM(mthd)  SUBC_SIFM(NV05_SIFM_##mthd)

#define SUBC_3D(mthd)    7, (mthd)
#define NV30_3D(mthd)    SUBC_3D(NV30_3D_##mthd)
#define NV40_3D(mthd)    SUBC_3D(NV40_3D_##mthd)

#define NV01_SUBC(subc, mthd) SUBC_##subc((NV01_SUBCHAN_##mthd))
#define NV11_SUBC(subc, mthd) SUBC_##subc((NV11_SUBCHAN_##mthd))

#define NV04_GRAPH(subc, mthd) SUBC_##subc((NV04_GRAPH_##mthd))

#endif