Commit 6f41c7c5 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/sw: convert to new-style nvkm_engine

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 97070f23
...@@ -3,33 +3,16 @@ ...@@ -3,33 +3,16 @@
#include <core/engine.h> #include <core/engine.h>
struct nvkm_sw { struct nvkm_sw {
struct nvkm_engine engine;
const struct nvkm_sw_func *func; const struct nvkm_sw_func *func;
struct nvkm_engine engine;
struct list_head chan; struct list_head chan;
}; };
bool nvkm_sw_mthd(struct nvkm_sw *sw, int chid, int subc, u32 mthd, u32 data); bool nvkm_sw_mthd(struct nvkm_sw *sw, int chid, int subc, u32 mthd, u32 data);
#define nvkm_sw_create(p,e,c,d) \ int nv04_sw_new(struct nvkm_device *, int, struct nvkm_sw **);
nvkm_sw_ctor((p), (e), (c), sizeof(**d), (void **)d) int nv10_sw_new(struct nvkm_device *, int, struct nvkm_sw **);
int int nv50_sw_new(struct nvkm_device *, int, struct nvkm_sw **);
nvkm_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine, int gf100_sw_new(struct nvkm_device *, int, struct nvkm_sw **);
struct nvkm_oclass *oclass, int length, void **pobject);
#define nvkm_sw_destroy(d) \
nvkm_engine_destroy(&(d)->engine)
#define nvkm_sw_init(d) \
nvkm_engine_init_old(&(d)->engine)
#define nvkm_sw_fini(d,s) \
nvkm_engine_fini_old(&(d)->engine, (s))
#define _nvkm_sw_dtor _nvkm_engine_dtor
#define _nvkm_sw_init _nvkm_engine_init
#define _nvkm_sw_fini _nvkm_engine_fini
extern struct nvkm_oclass *nv04_sw_oclass;
extern struct nvkm_oclass *nv10_sw_oclass;
extern struct nvkm_oclass *nv50_sw_oclass;
extern struct nvkm_oclass *gf100_sw_oclass;
void nv04_sw_intr(struct nvkm_subdev *);
#endif #endif
...@@ -28,31 +28,22 @@ gf100_identify(struct nvkm_device *device) ...@@ -28,31 +28,22 @@ gf100_identify(struct nvkm_device *device)
{ {
switch (device->chipset) { switch (device->chipset) {
case 0xc0: case 0xc0:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xc4: case 0xc4:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xc3: case 0xc3:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xce: case 0xce:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xcf: case 0xcf:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xc1: case 0xc1:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xc8: case 0xc8:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xd9: case 0xd9:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xd7: case 0xd7:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -28,28 +28,20 @@ gk104_identify(struct nvkm_device *device) ...@@ -28,28 +28,20 @@ gk104_identify(struct nvkm_device *device)
{ {
switch (device->chipset) { switch (device->chipset) {
case 0xe4: case 0xe4:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xe7: case 0xe7:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xe6: case 0xe6:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xea: case 0xea:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xf0: case 0xf0:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0xf1: case 0xf1:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0x106: case 0x106:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
case 0x108: case 0x108:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -31,7 +31,6 @@ gm100_identify(struct nvkm_device *device) ...@@ -31,7 +31,6 @@ gm100_identify(struct nvkm_device *device)
#if 0 #if 0
#endif #endif
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
#if 0 #if 0
#endif #endif
#if 0 #if 0
...@@ -44,7 +43,6 @@ gm100_identify(struct nvkm_device *device) ...@@ -44,7 +43,6 @@ gm100_identify(struct nvkm_device *device)
#endif #endif
#if 0 #if 0
#endif #endif
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
#if 0 #if 0
#endif #endif
break; break;
...@@ -55,13 +53,11 @@ gm100_identify(struct nvkm_device *device) ...@@ -55,13 +53,11 @@ gm100_identify(struct nvkm_device *device)
#endif #endif
#if 0 #if 0
#endif #endif
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
#if 0 #if 0
#endif #endif
break; break;
case 0x12b: case 0x12b:
device->oclass[NVDEV_ENGINE_SW ] = gf100_sw_oclass;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -28,10 +28,8 @@ nv04_identify(struct nvkm_device *device) ...@@ -28,10 +28,8 @@ nv04_identify(struct nvkm_device *device)
{ {
switch (device->chipset) { switch (device->chipset) {
case 0x04: case 0x04:
device->oclass[NVDEV_ENGINE_SW ] = nv04_sw_oclass;
break; break;
case 0x05: case 0x05:
device->oclass[NVDEV_ENGINE_SW ] = nv04_sw_oclass;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -30,25 +30,18 @@ nv10_identify(struct nvkm_device *device) ...@@ -30,25 +30,18 @@ nv10_identify(struct nvkm_device *device)
case 0x10: case 0x10:
break; break;
case 0x15: case 0x15:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x16: case 0x16:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x1a: case 0x1a:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x11: case 0x11:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x17: case 0x17:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x1f: case 0x1f:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x18: case 0x18:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -28,16 +28,12 @@ nv20_identify(struct nvkm_device *device) ...@@ -28,16 +28,12 @@ nv20_identify(struct nvkm_device *device)
{ {
switch (device->chipset) { switch (device->chipset) {
case 0x20: case 0x20:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x25: case 0x25:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x28: case 0x28:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x2a: case 0x2a:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -28,21 +28,16 @@ nv30_identify(struct nvkm_device *device) ...@@ -28,21 +28,16 @@ nv30_identify(struct nvkm_device *device)
{ {
switch (device->chipset) { switch (device->chipset) {
case 0x30: case 0x30:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x35: case 0x35:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
break; break;
case 0x31: case 0x31:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv31_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv31_mpeg_oclass;
break; break;
case 0x36: case 0x36:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv31_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv31_mpeg_oclass;
break; break;
case 0x34: case 0x34:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv31_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv31_mpeg_oclass;
break; break;
default: default:
......
...@@ -28,67 +28,51 @@ nv40_identify(struct nvkm_device *device) ...@@ -28,67 +28,51 @@ nv40_identify(struct nvkm_device *device)
{ {
switch (device->chipset) { switch (device->chipset) {
case 0x40: case 0x40:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv40_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv40_mpeg_oclass;
break; break;
case 0x41: case 0x41:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv40_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv40_mpeg_oclass;
break; break;
case 0x42: case 0x42:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv40_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv40_mpeg_oclass;
break; break;
case 0x43: case 0x43:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv40_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv40_mpeg_oclass;
break; break;
case 0x45: case 0x45:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x47: case 0x47:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x49: case 0x49:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x4b: case 0x4b:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x44: case 0x44:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x46: case 0x46:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x4a: case 0x4a:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x4c: case 0x4c:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x4e: case 0x4e:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x63: case 0x63:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x67: case 0x67:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
case 0x68: case 0x68:
device->oclass[NVDEV_ENGINE_SW ] = nv10_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv44_mpeg_oclass;
break; break;
default: default:
......
...@@ -28,54 +28,40 @@ nv50_identify(struct nvkm_device *device) ...@@ -28,54 +28,40 @@ nv50_identify(struct nvkm_device *device)
{ {
switch (device->chipset) { switch (device->chipset) {
case 0x50: case 0x50:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &nv50_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &nv50_mpeg_oclass;
break; break;
case 0x84: case 0x84:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass;
break; break;
case 0x86: case 0x86:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass;
break; break;
case 0x92: case 0x92:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass;
break; break;
case 0x94: case 0x94:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass;
break; break;
case 0x96: case 0x96:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass;
break; break;
case 0x98: case 0x98:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
break; break;
case 0xa0: case 0xa0:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass;
break; break;
case 0xaa: case 0xaa:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
break; break;
case 0xac: case 0xac:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
break; break;
case 0xa3: case 0xa3:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass; device->oclass[NVDEV_ENGINE_MPEG ] = &g84_mpeg_oclass;
break; break;
case 0xa5: case 0xa5:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
break; break;
case 0xa8: case 0xa8:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
break; break;
case 0xaf: case 0xaf:
device->oclass[NVDEV_ENGINE_SW ] = nv50_sw_oclass;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -82,26 +82,29 @@ nvkm_sw_cclass_get(struct nvkm_fifo_chan *fifoch, ...@@ -82,26 +82,29 @@ nvkm_sw_cclass_get(struct nvkm_fifo_chan *fifoch,
return sw->func->chan_new(sw, fifoch, oclass, pobject); return sw->func->chan_new(sw, fifoch, oclass, pobject);
} }
static void *
nvkm_sw_dtor(struct nvkm_engine *engine)
{
return nvkm_sw(engine);
}
static const struct nvkm_engine_func static const struct nvkm_engine_func
nvkm_sw = { nvkm_sw = {
.dtor = nvkm_sw_dtor,
.fifo.cclass = nvkm_sw_cclass_get, .fifo.cclass = nvkm_sw_cclass_get,
.fifo.sclass = nvkm_sw_oclass_get, .fifo.sclass = nvkm_sw_oclass_get,
}; };
int int
nvkm_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine, nvkm_sw_new_(const struct nvkm_sw_func *func, struct nvkm_device *device,
struct nvkm_oclass *oclass, int length, void **pobject) int index, struct nvkm_sw **psw)
{ {
struct nvkm_sw *sw; struct nvkm_sw *sw;
int ret;
ret = nvkm_engine_create_(parent, engine, oclass, true, "sw", if (!(sw = *psw = kzalloc(sizeof(*sw), GFP_KERNEL)))
"sw", length, pobject); return -ENOMEM;
sw = *pobject;
if (ret)
return ret;
sw->engine.func = &nvkm_sw;
INIT_LIST_HEAD(&sw->chan); INIT_LIST_HEAD(&sw->chan);
return 0; sw->func = func;
return nvkm_engine_ctor(&nvkm_sw, device, index, 0, true, &sw->engine);
} }
...@@ -140,7 +140,7 @@ gf100_sw_chan_new(struct nvkm_sw *sw, struct nvkm_fifo_chan *fifoch, ...@@ -140,7 +140,7 @@ gf100_sw_chan_new(struct nvkm_sw *sw, struct nvkm_fifo_chan *fifoch,
******************************************************************************/ ******************************************************************************/
static const struct nvkm_sw_func static const struct nvkm_sw_func
gf100_sw_func = { gf100_sw = {
.chan_new = gf100_sw_chan_new, .chan_new = gf100_sw_chan_new,
.sclass = { .sclass = {
{ nvkm_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_GF100 } }, { nvkm_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_GF100 } },
...@@ -148,14 +148,8 @@ gf100_sw_func = { ...@@ -148,14 +148,8 @@ gf100_sw_func = {
} }
}; };
struct nvkm_oclass * int
gf100_sw_oclass = &(struct nv50_sw_oclass) { gf100_sw_new(struct nvkm_device *device, int index, struct nvkm_sw **psw)
.base.handle = NV_ENGINE(SW, 0xc0), {
.base.ofuncs = &(struct nvkm_ofuncs) { return nvkm_sw_new_(&gf100_sw, device, index, psw);
.ctor = nv50_sw_ctor, }
.dtor = _nvkm_sw_dtor,
.init = _nvkm_sw_init,
.fini = _nvkm_sw_fini,
},
.func = &gf100_sw_func,
}.base;
...@@ -122,12 +122,6 @@ nv04_sw_chan_new(struct nvkm_sw *sw, struct nvkm_fifo_chan *fifo, ...@@ -122,12 +122,6 @@ nv04_sw_chan_new(struct nvkm_sw *sw, struct nvkm_fifo_chan *fifo,
* software engine/subdev functions * software engine/subdev functions
******************************************************************************/ ******************************************************************************/
void
nv04_sw_intr(struct nvkm_subdev *subdev)
{
nvkm_mask(subdev->device, 0x000100, 0x80000000, 0x00000000);
}
static const struct nvkm_sw_func static const struct nvkm_sw_func
nv04_sw = { nv04_sw = {
.chan_new = nv04_sw_chan_new, .chan_new = nv04_sw_chan_new,
...@@ -137,31 +131,8 @@ nv04_sw = { ...@@ -137,31 +131,8 @@ nv04_sw = {
} }
}; };
static int int
nv04_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine, nv04_sw_new(struct nvkm_device *device, int index, struct nvkm_sw **psw)
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{ {
struct nvkm_sw *sw; return nvkm_sw_new_(&nv04_sw, device, index, psw);
int ret;
ret = nvkm_sw_create(parent, engine, oclass, &sw);
*pobject = nv_object(sw);
if (ret)
return ret;
sw->func = &nv04_sw;
nv_subdev(sw)->intr = nv04_sw_intr;
return 0;
} }
struct nvkm_oclass *
nv04_sw_oclass = &(struct nvkm_oclass) {
.handle = NV_ENGINE(SW, 0x04),
.ofuncs = &(struct nvkm_ofuncs) {
.ctor = nv04_sw_ctor,
.dtor = _nvkm_sw_dtor,
.init = _nvkm_sw_init,
.fini = _nvkm_sw_fini,
},
};
...@@ -61,31 +61,8 @@ nv10_sw = { ...@@ -61,31 +61,8 @@ nv10_sw = {
} }
}; };
static int int
nv10_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine, nv10_sw_new(struct nvkm_device *device, int index, struct nvkm_sw **psw)
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{ {
struct nvkm_sw *sw; return nvkm_sw_new_(&nv10_sw, device, index, psw);
int ret;
ret = nvkm_sw_create(parent, engine, oclass, &sw);
*pobject = nv_object(sw);
if (ret)
return ret;
sw->func = &nv10_sw;
nv_subdev(sw)->intr = nv04_sw_intr;
return 0;
} }
struct nvkm_oclass *
nv10_sw_oclass = &(struct nvkm_oclass) {
.handle = NV_ENGINE(SW, 0x10),
.ofuncs = &(struct nvkm_ofuncs) {
.ctor = nv10_sw_ctor,
.dtor = _nvkm_sw_dtor,
.init = _nvkm_sw_init,
.fini = _nvkm_sw_fini,
},
};
...@@ -48,7 +48,7 @@ nv50_sw_chan_vblsem_release(struct nvkm_notify *notify) ...@@ -48,7 +48,7 @@ nv50_sw_chan_vblsem_release(struct nvkm_notify *notify)
nvkm_wr32(device, 0x001710, 0x80000000 | chan->vblank.ctxdma); nvkm_wr32(device, 0x001710, 0x80000000 | chan->vblank.ctxdma);
nvkm_bar_flush(device->bar); nvkm_bar_flush(device->bar);
if (nv_device(sw)->chipset == 0x50) { if (device->chipset == 0x50) {
nvkm_wr32(device, 0x001570, chan->vblank.offset); nvkm_wr32(device, 0x001570, chan->vblank.offset);
nvkm_wr32(device, 0x001574, chan->vblank.value); nvkm_wr32(device, 0x001574, chan->vblank.value);
} else { } else {
...@@ -133,27 +133,8 @@ nv50_sw_chan_new(struct nvkm_sw *sw, struct nvkm_fifo_chan *fifoch, ...@@ -133,27 +133,8 @@ nv50_sw_chan_new(struct nvkm_sw *sw, struct nvkm_fifo_chan *fifoch,
* software engine/subdev functions * software engine/subdev functions
******************************************************************************/ ******************************************************************************/
int
nv50_sw_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv50_sw_oclass *pclass = (void *)oclass;
struct nvkm_sw *sw;
int ret;
ret = nvkm_sw_create(parent, engine, oclass, &sw);
*pobject = nv_object(sw);
if (ret)
return ret;
sw->func = pclass->func;
nv_subdev(sw)->intr = nv04_sw_intr;
return 0;
}
static const struct nvkm_sw_func static const struct nvkm_sw_func
nv50_sw_func = { nv50_sw = {
.chan_new = nv50_sw_chan_new, .chan_new = nv50_sw_chan_new,
.sclass = { .sclass = {
{ nvkm_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_NV50 } }, { nvkm_nvsw_new, { -1, -1, NVIF_IOCTL_NEW_V0_SW_NV50 } },
...@@ -161,14 +142,8 @@ nv50_sw_func = { ...@@ -161,14 +142,8 @@ nv50_sw_func = {
} }
}; };
struct nvkm_oclass * int
nv50_sw_oclass = &(struct nv50_sw_oclass) { nv50_sw_new(struct nvkm_device *device, int index, struct nvkm_sw **psw)
.base.handle = NV_ENGINE(SW, 0x50), {
.base.ofuncs = &(struct nvkm_ofuncs) { return nvkm_sw_new_(&nv50_sw, device, index, psw);
.ctor = nv50_sw_ctor, }
.dtor = _nvkm_sw_dtor,
.init = _nvkm_sw_init,
.fini = _nvkm_sw_fini,
},
.func = &nv50_sw_func,
}.base;
...@@ -6,21 +6,6 @@ ...@@ -6,21 +6,6 @@
#include "nvsw.h" #include "nvsw.h"
#include <core/notify.h> #include <core/notify.h>
struct nv50_sw_oclass {
struct nvkm_oclass base;
const struct nvkm_sw_func *func;
};
int nv50_sw_ctor(struct nvkm_object *, struct nvkm_object *,
struct nvkm_oclass *, void *, u32,
struct nvkm_object **);
struct nv50_sw_cclass {
struct nvkm_oclass base;
int (*vblank)(struct nvkm_notify *);
const struct nvkm_sw_chan_func *chan;
};
struct nv50_sw_chan { struct nv50_sw_chan {
struct nvkm_sw_chan base; struct nvkm_sw_chan base;
struct { struct {
......
...@@ -27,18 +27,19 @@ ...@@ -27,18 +27,19 @@
#include <nvif/class.h> #include <nvif/class.h>
static int static int
nvkm_nvsw_mthd_(struct nvkm_object *base, u32 mthd, void *data, u32 size) nvkm_nvsw_mthd_(struct nvkm_object *object, u32 mthd, void *data, u32 size)
{ {
struct nvkm_nvsw *nvsw = nvkm_nvsw(base); struct nvkm_nvsw *nvsw = nvkm_nvsw(object);
if (nvsw->func->mthd) if (nvsw->func->mthd)
return nvsw->func->mthd(nvsw, mthd, data, size); return nvsw->func->mthd(nvsw, mthd, data, size);
return -ENODEV; return -ENODEV;
} }
static int static int
nvkm_nvsw_ntfy_(struct nvkm_object *base, u32 mthd, struct nvkm_event **pevent) nvkm_nvsw_ntfy_(struct nvkm_object *object, u32 mthd,
struct nvkm_event **pevent)
{ {
struct nvkm_nvsw *nvsw = nvkm_nvsw(base); struct nvkm_nvsw *nvsw = nvkm_nvsw(object);
switch (mthd) { switch (mthd) {
case NVSW_NTFY_UEVENT: case NVSW_NTFY_UEVENT:
*pevent = &nvsw->chan->event; *pevent = &nvsw->chan->event;
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include <engine/sw.h> #include <engine/sw.h>
struct nvkm_sw_chan; struct nvkm_sw_chan;
int nvkm_sw_new_(const struct nvkm_sw_func *, struct nvkm_device *,
int index, struct nvkm_sw **);
struct nvkm_sw_chan_sclass { struct nvkm_sw_chan_sclass {
int (*ctor)(struct nvkm_sw_chan *, const struct nvkm_oclass *, int (*ctor)(struct nvkm_sw_chan *, const struct nvkm_oclass *,
void *data, u32 size, struct nvkm_object **); void *data, u32 size, struct nvkm_object **);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment