Commit 3a900a5d authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/nvdec: initialise SW state for falcon from constructor

This will allow us to register the falcon with ACR, and further customise
its behaviour by providing the nvkm_falcon_func structure directly.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 98a34d99
...@@ -3,13 +3,12 @@ ...@@ -3,13 +3,12 @@
#define __NVKM_NVDEC_H__ #define __NVKM_NVDEC_H__
#define nvkm_nvdec(p) container_of((p), struct nvkm_nvdec, engine) #define nvkm_nvdec(p) container_of((p), struct nvkm_nvdec, engine)
#include <core/engine.h> #include <core/engine.h>
#include <core/falcon.h>
struct nvkm_nvdec { struct nvkm_nvdec {
const struct nvkm_nvdec_func *func; const struct nvkm_nvdec_func *func;
struct nvkm_engine engine; struct nvkm_engine engine;
u32 addr; struct nvkm_falcon falcon;
struct nvkm_falcon *falcon;
}; };
int gp102_nvdec_new(struct nvkm_device *, int, struct nvkm_nvdec **); int gp102_nvdec_new(struct nvkm_device *, int, struct nvkm_nvdec **);
......
...@@ -20,38 +20,19 @@ ...@@ -20,38 +20,19 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
#include "priv.h" #include "priv.h"
#include <core/firmware.h> #include <core/firmware.h>
#include <subdev/top.h>
#include <engine/falcon.h>
static int
nvkm_nvdec_oneinit(struct nvkm_engine *engine)
{
struct nvkm_nvdec *nvdec = nvkm_nvdec(engine);
struct nvkm_subdev *subdev = &nvdec->engine.subdev;
nvdec->addr = nvkm_top_addr(subdev->device, subdev->index);
if (!nvdec->addr)
return -EINVAL;
/*XXX: fix naming of this when adding support for multiple-NVDEC */
return nvkm_falcon_v1_new(subdev, "NVDEC", nvdec->addr,
&nvdec->falcon);
}
static void * static void *
nvkm_nvdec_dtor(struct nvkm_engine *engine) nvkm_nvdec_dtor(struct nvkm_engine *engine)
{ {
struct nvkm_nvdec *nvdec = nvkm_nvdec(engine); struct nvkm_nvdec *nvdec = nvkm_nvdec(engine);
nvkm_falcon_del(&nvdec->falcon); nvkm_falcon_dtor(&nvdec->falcon);
return nvdec; return nvdec;
} }
static const struct nvkm_engine_func static const struct nvkm_engine_func
nvkm_nvdec = { nvkm_nvdec = {
.dtor = nvkm_nvdec_dtor, .dtor = nvkm_nvdec_dtor,
.oneinit = nvkm_nvdec_oneinit,
}; };
int int
...@@ -74,5 +55,7 @@ nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *device, ...@@ -74,5 +55,7 @@ nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *device,
return -ENODEV; return -ENODEV;
nvdec->func = fwif->func; nvdec->func = fwif->func;
return 0;
return nvkm_falcon_ctor(nvdec->func->flcn, &nvdec->engine.subdev,
nvkm_subdev_name[index], 0, &nvdec->falcon);
}; };
...@@ -21,8 +21,23 @@ ...@@ -21,8 +21,23 @@
*/ */
#include "priv.h" #include "priv.h"
static const struct nvkm_falcon_func
gp102_nvdec_flcn = {
.load_imem = nvkm_falcon_v1_load_imem,
.load_dmem = nvkm_falcon_v1_load_dmem,
.read_dmem = nvkm_falcon_v1_read_dmem,
.bind_context = nvkm_falcon_v1_bind_context,
.wait_for_halt = nvkm_falcon_v1_wait_for_halt,
.clear_interrupt = nvkm_falcon_v1_clear_interrupt,
.set_start_addr = nvkm_falcon_v1_set_start_addr,
.start = nvkm_falcon_v1_start,
.enable = nvkm_falcon_v1_enable,
.disable = nvkm_falcon_v1_disable,
};
static const struct nvkm_nvdec_func static const struct nvkm_nvdec_func
gp102_nvdec = { gp102_nvdec = {
.flcn = &gp102_nvdec_flcn,
}; };
static int static int
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <engine/nvdec.h> #include <engine/nvdec.h>
struct nvkm_nvdec_func { struct nvkm_nvdec_func {
const struct nvkm_falcon_func *flcn;
}; };
struct nvkm_nvdec_fwif { struct nvkm_nvdec_fwif {
......
...@@ -62,7 +62,7 @@ gp102_run_secure_scrub(struct nvkm_secboot *sb) ...@@ -62,7 +62,7 @@ gp102_run_secure_scrub(struct nvkm_secboot *sb)
engine = nvkm_engine_ref(&device->nvdec[0]->engine); engine = nvkm_engine_ref(&device->nvdec[0]->engine);
if (IS_ERR(engine)) if (IS_ERR(engine))
return PTR_ERR(engine); return PTR_ERR(engine);
falcon = device->nvdec[0]->falcon; falcon = &device->nvdec[0]->falcon;
nvkm_falcon_get(falcon, &sb->subdev); nvkm_falcon_get(falcon, &sb->subdev);
......
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