1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <engine/sw.h>
25#include <engine/fifo.h>
26
27struct nv04_sw_priv {
28 struct nvkm_sw base;
29};
30
31struct nv04_sw_chan {
32 struct nvkm_sw_chan base;
33};
34
35
36
37
38
39static int
40nv04_sw_set_ref(struct nvkm_object *object, u32 mthd, void *data, u32 size)
41{
42 struct nvkm_object *channel = (void *)nv_engctx(object->parent);
43 struct nvkm_fifo_chan *fifo = (void *)channel->parent;
44 atomic_set(&fifo->refcnt, *(u32*)data);
45 return 0;
46}
47
48static int
49nv04_sw_flip(struct nvkm_object *object, u32 mthd, void *args, u32 size)
50{
51 struct nv04_sw_chan *chan = (void *)nv_engctx(object->parent);
52 if (chan->base.flip)
53 return chan->base.flip(chan->base.flip_data);
54 return -EINVAL;
55}
56
57static struct nvkm_omthds
58nv04_sw_omthds[] = {
59 { 0x0150, 0x0150, nv04_sw_set_ref },
60 { 0x0500, 0x0500, nv04_sw_flip },
61 {}
62};
63
64static struct nvkm_oclass
65nv04_sw_sclass[] = {
66 { 0x006e, &nvkm_object_ofuncs, nv04_sw_omthds },
67 {}
68};
69
70
71
72
73
74static int
75nv04_sw_context_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
76 struct nvkm_oclass *oclass, void *data, u32 size,
77 struct nvkm_object **pobject)
78{
79 struct nv04_sw_chan *chan;
80 int ret;
81
82 ret = nvkm_sw_context_create(parent, engine, oclass, &chan);
83 *pobject = nv_object(chan);
84 if (ret)
85 return ret;
86
87 return 0;
88}
89
90static struct nvkm_oclass
91nv04_sw_cclass = {
92 .handle = NV_ENGCTX(SW, 0x04),
93 .ofuncs = &(struct nvkm_ofuncs) {
94 .ctor = nv04_sw_context_ctor,
95 .dtor = _nvkm_sw_context_dtor,
96 .init = _nvkm_sw_context_init,
97 .fini = _nvkm_sw_context_fini,
98 },
99};
100
101
102
103
104
105void
106nv04_sw_intr(struct nvkm_subdev *subdev)
107{
108 nv_mask(subdev, 0x000100, 0x80000000, 0x00000000);
109}
110
111static int
112nv04_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
113 struct nvkm_oclass *oclass, void *data, u32 size,
114 struct nvkm_object **pobject)
115{
116 struct nv04_sw_priv *priv;
117 int ret;
118
119 ret = nvkm_sw_create(parent, engine, oclass, &priv);
120 *pobject = nv_object(priv);
121 if (ret)
122 return ret;
123
124 nv_engine(priv)->cclass = &nv04_sw_cclass;
125 nv_engine(priv)->sclass = nv04_sw_sclass;
126 nv_subdev(priv)->intr = nv04_sw_intr;
127 return 0;
128}
129
130struct nvkm_oclass *
131nv04_sw_oclass = &(struct nvkm_oclass) {
132 .handle = NV_ENGINE(SW, 0x04),
133 .ofuncs = &(struct nvkm_ofuncs) {
134 .ctor = nv04_sw_ctor,
135 .dtor = _nvkm_sw_dtor,
136 .init = _nvkm_sw_init,
137 .fini = _nvkm_sw_fini,
138 },
139};
140