diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2013-10-02 17:42:41 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2013-11-08 00:36:05 -0500 |
commit | 7589563eb34527fd1f357a1ef0dbb7ee6b02af1c (patch) | |
tree | 4a65c0986fe16d9da18f2b8915ca005164b4c0b1 | |
parent | c46c3ddf1f5bbc4fbd2cd661a9e8f0ba3daf5298 (diff) |
drm/nv50-/sw: share engine/channel constructor between implementations
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/core/engine/software/nv50.c | 21 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/core/engine/software/nv50.h | 16 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/core/engine/software/nvc0.c | 51 |
3 files changed, 37 insertions, 51 deletions
diff --git a/drivers/gpu/drm/nouveau/core/engine/software/nv50.c b/drivers/gpu/drm/nouveau/core/engine/software/nv50.c index 591784078823..5236a1430ef6 100644 --- a/drivers/gpu/drm/nouveau/core/engine/software/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/software/nv50.c | |||
@@ -147,12 +147,13 @@ nv50_software_vblsem_release(struct nouveau_eventh *event, int head) | |||
147 | return NVKM_EVENT_DROP; | 147 | return NVKM_EVENT_DROP; |
148 | } | 148 | } |
149 | 149 | ||
150 | static int | 150 | int |
151 | nv50_software_context_ctor(struct nouveau_object *parent, | 151 | nv50_software_context_ctor(struct nouveau_object *parent, |
152 | struct nouveau_object *engine, | 152 | struct nouveau_object *engine, |
153 | struct nouveau_oclass *oclass, void *data, u32 size, | 153 | struct nouveau_oclass *oclass, void *data, u32 size, |
154 | struct nouveau_object **pobject) | 154 | struct nouveau_object **pobject) |
155 | { | 155 | { |
156 | struct nv50_software_cclass *pclass = (void *)oclass; | ||
156 | struct nv50_software_chan *chan; | 157 | struct nv50_software_chan *chan; |
157 | int ret; | 158 | int ret; |
158 | 159 | ||
@@ -162,30 +163,32 @@ nv50_software_context_ctor(struct nouveau_object *parent, | |||
162 | return ret; | 163 | return ret; |
163 | 164 | ||
164 | chan->vblank.channel = nv_gpuobj(parent->parent)->addr >> 12; | 165 | chan->vblank.channel = nv_gpuobj(parent->parent)->addr >> 12; |
165 | chan->vblank.event.func = nv50_software_vblsem_release; | 166 | chan->vblank.event.func = pclass->vblank; |
166 | return 0; | 167 | return 0; |
167 | } | 168 | } |
168 | 169 | ||
169 | static struct nouveau_oclass | 170 | static struct nv50_software_cclass |
170 | nv50_software_cclass = { | 171 | nv50_software_cclass = { |
171 | .handle = NV_ENGCTX(SW, 0x50), | 172 | .base.handle = NV_ENGCTX(SW, 0x50), |
172 | .ofuncs = &(struct nouveau_ofuncs) { | 173 | .base.ofuncs = &(struct nouveau_ofuncs) { |
173 | .ctor = nv50_software_context_ctor, | 174 | .ctor = nv50_software_context_ctor, |
174 | .dtor = _nouveau_software_context_dtor, | 175 | .dtor = _nouveau_software_context_dtor, |
175 | .init = _nouveau_software_context_init, | 176 | .init = _nouveau_software_context_init, |
176 | .fini = _nouveau_software_context_fini, | 177 | .fini = _nouveau_software_context_fini, |
177 | }, | 178 | }, |
179 | .vblank = nv50_software_vblsem_release, | ||
178 | }; | 180 | }; |
179 | 181 | ||
180 | /******************************************************************************* | 182 | /******************************************************************************* |
181 | * software engine/subdev functions | 183 | * software engine/subdev functions |
182 | ******************************************************************************/ | 184 | ******************************************************************************/ |
183 | 185 | ||
184 | static int | 186 | int |
185 | nv50_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | 187 | nv50_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine, |
186 | struct nouveau_oclass *oclass, void *data, u32 size, | 188 | struct nouveau_oclass *oclass, void *data, u32 size, |
187 | struct nouveau_object **pobject) | 189 | struct nouveau_object **pobject) |
188 | { | 190 | { |
191 | struct nv50_software_oclass *pclass = (void *)oclass; | ||
189 | struct nv50_software_priv *priv; | 192 | struct nv50_software_priv *priv; |
190 | int ret; | 193 | int ret; |
191 | 194 | ||
@@ -194,8 +197,8 @@ nv50_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | |||
194 | if (ret) | 197 | if (ret) |
195 | return ret; | 198 | return ret; |
196 | 199 | ||
197 | nv_engine(priv)->cclass = &nv50_software_cclass; | 200 | nv_engine(priv)->cclass = pclass->cclass; |
198 | nv_engine(priv)->sclass = nv50_software_sclass; | 201 | nv_engine(priv)->sclass = pclass->sclass; |
199 | nv_subdev(priv)->intr = nv04_software_intr; | 202 | nv_subdev(priv)->intr = nv04_software_intr; |
200 | return 0; | 203 | return 0; |
201 | } | 204 | } |
@@ -209,4 +212,6 @@ nv50_software_oclass = &(struct nv50_software_oclass) { | |||
209 | .init = _nouveau_software_init, | 212 | .init = _nouveau_software_init, |
210 | .fini = _nouveau_software_fini, | 213 | .fini = _nouveau_software_fini, |
211 | }, | 214 | }, |
215 | .cclass = &nv50_software_cclass.base, | ||
216 | .sclass = nv50_software_sclass, | ||
212 | }.base; | 217 | }.base; |
diff --git a/drivers/gpu/drm/nouveau/core/engine/software/nv50.h b/drivers/gpu/drm/nouveau/core/engine/software/nv50.h index 628b97ba2ed1..2c0b1b42b861 100644 --- a/drivers/gpu/drm/nouveau/core/engine/software/nv50.h +++ b/drivers/gpu/drm/nouveau/core/engine/software/nv50.h | |||
@@ -5,12 +5,23 @@ | |||
5 | 5 | ||
6 | struct nv50_software_oclass { | 6 | struct nv50_software_oclass { |
7 | struct nouveau_oclass base; | 7 | struct nouveau_oclass base; |
8 | struct nouveau_oclass *cclass; | ||
9 | struct nouveau_oclass *sclass; | ||
8 | }; | 10 | }; |
9 | 11 | ||
10 | struct nv50_software_priv { | 12 | struct nv50_software_priv { |
11 | struct nouveau_software base; | 13 | struct nouveau_software base; |
12 | }; | 14 | }; |
13 | 15 | ||
16 | int nv50_software_ctor(struct nouveau_object *, struct nouveau_object *, | ||
17 | struct nouveau_oclass *, void *, u32, | ||
18 | struct nouveau_object **); | ||
19 | |||
20 | struct nv50_software_cclass { | ||
21 | struct nouveau_oclass base; | ||
22 | int (*vblank)(struct nouveau_eventh *, int); | ||
23 | }; | ||
24 | |||
14 | struct nv50_software_chan { | 25 | struct nv50_software_chan { |
15 | struct nouveau_software_chan base; | 26 | struct nouveau_software_chan base; |
16 | struct { | 27 | struct { |
@@ -22,4 +33,9 @@ struct nv50_software_chan { | |||
22 | } vblank; | 33 | } vblank; |
23 | }; | 34 | }; |
24 | 35 | ||
36 | int nv50_software_context_ctor(struct nouveau_object *, | ||
37 | struct nouveau_object *, | ||
38 | struct nouveau_oclass *, void *, u32, | ||
39 | struct nouveau_object **); | ||
40 | |||
25 | #endif | 41 | #endif |
diff --git a/drivers/gpu/drm/nouveau/core/engine/software/nvc0.c b/drivers/gpu/drm/nouveau/core/engine/software/nvc0.c index 69d871d7f76e..27e47230e3e3 100644 --- a/drivers/gpu/drm/nouveau/core/engine/software/nvc0.c +++ b/drivers/gpu/drm/nouveau/core/engine/software/nvc0.c | |||
@@ -154,66 +154,31 @@ nvc0_software_vblsem_release(struct nouveau_eventh *event, int head) | |||
154 | return NVKM_EVENT_DROP; | 154 | return NVKM_EVENT_DROP; |
155 | } | 155 | } |
156 | 156 | ||
157 | static int | 157 | static struct nv50_software_cclass |
158 | nvc0_software_context_ctor(struct nouveau_object *parent, | ||
159 | struct nouveau_object *engine, | ||
160 | struct nouveau_oclass *oclass, void *data, u32 size, | ||
161 | struct nouveau_object **pobject) | ||
162 | { | ||
163 | struct nv50_software_chan *chan; | ||
164 | int ret; | ||
165 | |||
166 | ret = nouveau_software_context_create(parent, engine, oclass, &chan); | ||
167 | *pobject = nv_object(chan); | ||
168 | if (ret) | ||
169 | return ret; | ||
170 | |||
171 | chan->vblank.channel = nv_gpuobj(parent->parent)->addr >> 12; | ||
172 | chan->vblank.event.func = nvc0_software_vblsem_release; | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static struct nouveau_oclass | ||
177 | nvc0_software_cclass = { | 158 | nvc0_software_cclass = { |
178 | .handle = NV_ENGCTX(SW, 0xc0), | 159 | .base.handle = NV_ENGCTX(SW, 0xc0), |
179 | .ofuncs = &(struct nouveau_ofuncs) { | 160 | .base.ofuncs = &(struct nouveau_ofuncs) { |
180 | .ctor = nvc0_software_context_ctor, | 161 | .ctor = nv50_software_context_ctor, |
181 | .dtor = _nouveau_software_context_dtor, | 162 | .dtor = _nouveau_software_context_dtor, |
182 | .init = _nouveau_software_context_init, | 163 | .init = _nouveau_software_context_init, |
183 | .fini = _nouveau_software_context_fini, | 164 | .fini = _nouveau_software_context_fini, |
184 | }, | 165 | }, |
166 | .vblank = nvc0_software_vblsem_release, | ||
185 | }; | 167 | }; |
186 | 168 | ||
187 | /******************************************************************************* | 169 | /******************************************************************************* |
188 | * software engine/subdev functions | 170 | * software engine/subdev functions |
189 | ******************************************************************************/ | 171 | ******************************************************************************/ |
190 | 172 | ||
191 | static int | ||
192 | nvc0_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine, | ||
193 | struct nouveau_oclass *oclass, void *data, u32 size, | ||
194 | struct nouveau_object **pobject) | ||
195 | { | ||
196 | struct nv50_software_priv *priv; | ||
197 | int ret; | ||
198 | |||
199 | ret = nouveau_software_create(parent, engine, oclass, &priv); | ||
200 | *pobject = nv_object(priv); | ||
201 | if (ret) | ||
202 | return ret; | ||
203 | |||
204 | nv_engine(priv)->cclass = &nvc0_software_cclass; | ||
205 | nv_engine(priv)->sclass = nvc0_software_sclass; | ||
206 | nv_subdev(priv)->intr = nv04_software_intr; | ||
207 | return 0; | ||
208 | } | ||
209 | |||
210 | struct nouveau_oclass * | 173 | struct nouveau_oclass * |
211 | nvc0_software_oclass = &(struct nv50_software_oclass) { | 174 | nvc0_software_oclass = &(struct nv50_software_oclass) { |
212 | .base.handle = NV_ENGINE(SW, 0xc0), | 175 | .base.handle = NV_ENGINE(SW, 0xc0), |
213 | .base.ofuncs = &(struct nouveau_ofuncs) { | 176 | .base.ofuncs = &(struct nouveau_ofuncs) { |
214 | .ctor = nvc0_software_ctor, | 177 | .ctor = nv50_software_ctor, |
215 | .dtor = _nouveau_software_dtor, | 178 | .dtor = _nouveau_software_dtor, |
216 | .init = _nouveau_software_init, | 179 | .init = _nouveau_software_init, |
217 | .fini = _nouveau_software_fini, | 180 | .fini = _nouveau_software_fini, |
218 | }, | 181 | }, |
182 | .cclass = &nvc0_software_cclass.base, | ||
183 | .sclass = nvc0_software_sclass, | ||
219 | }.base; | 184 | }.base; |