Commit 7589563e authored by Ben Skeggs's avatar Ben Skeggs

drm/nv50-/sw: share engine/channel constructor between implementations

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent c46c3ddf
......@@ -147,12 +147,13 @@ nv50_software_vblsem_release(struct nouveau_eventh *event, int head)
return NVKM_EVENT_DROP;
}
static int
int
nv50_software_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nv50_software_cclass *pclass = (void *)oclass;
struct nv50_software_chan *chan;
int ret;
......@@ -162,30 +163,32 @@ nv50_software_context_ctor(struct nouveau_object *parent,
return ret;
chan->vblank.channel = nv_gpuobj(parent->parent)->addr >> 12;
chan->vblank.event.func = nv50_software_vblsem_release;
chan->vblank.event.func = pclass->vblank;
return 0;
}
static struct nouveau_oclass
static struct nv50_software_cclass
nv50_software_cclass = {
.handle = NV_ENGCTX(SW, 0x50),
.ofuncs = &(struct nouveau_ofuncs) {
.base.handle = NV_ENGCTX(SW, 0x50),
.base.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nv50_software_context_ctor,
.dtor = _nouveau_software_context_dtor,
.init = _nouveau_software_context_init,
.fini = _nouveau_software_context_fini,
},
.vblank = nv50_software_vblsem_release,
};
/*******************************************************************************
* software engine/subdev functions
******************************************************************************/
static int
int
nv50_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nv50_software_oclass *pclass = (void *)oclass;
struct nv50_software_priv *priv;
int ret;
......@@ -194,8 +197,8 @@ nv50_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
if (ret)
return ret;
nv_engine(priv)->cclass = &nv50_software_cclass;
nv_engine(priv)->sclass = nv50_software_sclass;
nv_engine(priv)->cclass = pclass->cclass;
nv_engine(priv)->sclass = pclass->sclass;
nv_subdev(priv)->intr = nv04_software_intr;
return 0;
}
......@@ -209,4 +212,6 @@ nv50_software_oclass = &(struct nv50_software_oclass) {
.init = _nouveau_software_init,
.fini = _nouveau_software_fini,
},
.cclass = &nv50_software_cclass.base,
.sclass = nv50_software_sclass,
}.base;
......@@ -5,12 +5,23 @@
struct nv50_software_oclass {
struct nouveau_oclass base;
struct nouveau_oclass *cclass;
struct nouveau_oclass *sclass;
};
struct nv50_software_priv {
struct nouveau_software base;
};
int nv50_software_ctor(struct nouveau_object *, struct nouveau_object *,
struct nouveau_oclass *, void *, u32,
struct nouveau_object **);
struct nv50_software_cclass {
struct nouveau_oclass base;
int (*vblank)(struct nouveau_eventh *, int);
};
struct nv50_software_chan {
struct nouveau_software_chan base;
struct {
......@@ -22,4 +33,9 @@ struct nv50_software_chan {
} vblank;
};
int nv50_software_context_ctor(struct nouveau_object *,
struct nouveau_object *,
struct nouveau_oclass *, void *, u32,
struct nouveau_object **);
#endif
......@@ -154,66 +154,31 @@ nvc0_software_vblsem_release(struct nouveau_eventh *event, int head)
return NVKM_EVENT_DROP;
}
static int
nvc0_software_context_ctor(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nv50_software_chan *chan;
int ret;
ret = nouveau_software_context_create(parent, engine, oclass, &chan);
*pobject = nv_object(chan);
if (ret)
return ret;
chan->vblank.channel = nv_gpuobj(parent->parent)->addr >> 12;
chan->vblank.event.func = nvc0_software_vblsem_release;
return 0;
}
static struct nouveau_oclass
static struct nv50_software_cclass
nvc0_software_cclass = {
.handle = NV_ENGCTX(SW, 0xc0),
.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nvc0_software_context_ctor,
.base.handle = NV_ENGCTX(SW, 0xc0),
.base.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nv50_software_context_ctor,
.dtor = _nouveau_software_context_dtor,
.init = _nouveau_software_context_init,
.fini = _nouveau_software_context_fini,
},
.vblank = nvc0_software_vblsem_release,
};
/*******************************************************************************
* software engine/subdev functions
******************************************************************************/
static int
nvc0_software_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
{
struct nv50_software_priv *priv;
int ret;
ret = nouveau_software_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;
nv_engine(priv)->cclass = &nvc0_software_cclass;
nv_engine(priv)->sclass = nvc0_software_sclass;
nv_subdev(priv)->intr = nv04_software_intr;
return 0;
}
struct nouveau_oclass *
nvc0_software_oclass = &(struct nv50_software_oclass) {
.base.handle = NV_ENGINE(SW, 0xc0),
.base.ofuncs = &(struct nouveau_ofuncs) {
.ctor = nvc0_software_ctor,
.ctor = nv50_software_ctor,
.dtor = _nouveau_software_dtor,
.init = _nouveau_software_init,
.fini = _nouveau_software_fini,
},
.cclass = &nvc0_software_cclass.base,
.sclass = nvc0_software_sclass,
}.base;
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