drm/nouveau/nvdec: select implementation based on available fw
authorBen Skeggs <bskeggs@redhat.com>
Tue, 14 Jan 2020 20:34:21 +0000 (06:34 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 15 Jan 2020 00:50:27 +0000 (10:50 +1000)
This will allow for further customisation of the subdev depending on what
firmware is available.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/base.c
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/gp102.c
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/priv.h

index 7c7d7f0abfccc991289fe64a87803442070c2530..b941fbf465d1fef6b01141227317ecb52b586a9b 100644 (file)
@@ -5,6 +5,7 @@
 #include <core/engine.h>
 
 struct nvkm_nvdec {
+       const struct nvkm_nvdec_func *func;
        struct nvkm_engine engine;
        u32 addr;
 
index 4a63581bdd5e174a575982a48335197bc1c1561c..ae7a7616113a4874b97d521c4410c9525ab6b6b7 100644 (file)
@@ -21,6 +21,7 @@
  */
 #include "priv.h"
 
+#include <core/firmware.h>
 #include <subdev/top.h>
 #include <engine/falcon.h>
 
@@ -54,14 +55,24 @@ nvkm_nvdec = {
 };
 
 int
-nvkm_nvdec_new_(struct nvkm_device *device, int index,
-               struct nvkm_nvdec **pnvdec)
+nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif, struct nvkm_device *device,
+               int index, struct nvkm_nvdec **pnvdec)
 {
        struct nvkm_nvdec *nvdec;
+       int ret;
 
        if (!(nvdec = *pnvdec = kzalloc(sizeof(*nvdec), GFP_KERNEL)))
                return -ENOMEM;
 
-       return nvkm_engine_ctor(&nvkm_nvdec, device, index, true,
-                               &nvdec->engine);
+       ret = nvkm_engine_ctor(&nvkm_nvdec, device, index, true,
+                              &nvdec->engine);
+       if (ret)
+               return ret;
+
+       fwif = nvkm_firmware_load(&nvdec->engine.subdev, fwif, "Nvdec", nvdec);
+       if (IS_ERR(fwif))
+               return -ENODEV;
+
+       nvdec->func = fwif->func;
+       return 0;
 };
index fde6328c6d7134244b4e7a99693031420902ef6e..f2cc69c424b1abc287b52c02b874fab662899fb9 100644 (file)
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-
 #include "priv.h"
 
+static const struct nvkm_nvdec_func
+gp102_nvdec = {
+};
+
+static int
+gp102_nvdec_nofw(struct nvkm_nvdec *nvdec, int ver,
+                const struct nvkm_nvdec_fwif *fwif)
+{
+       return 0;
+}
+
+static const struct nvkm_nvdec_fwif
+gp102_nvdec_fwif[] = {
+       { -1, gp102_nvdec_nofw, &gp102_nvdec },
+       {}
+};
+
 int
 gp102_nvdec_new(struct nvkm_device *device, int index,
                struct nvkm_nvdec **pnvdec)
 {
-       return nvkm_nvdec_new_(device, index, pnvdec);
+       return nvkm_nvdec_new_(gp102_nvdec_fwif, device, index, pnvdec);
 }
index 57bfa3aa1835ef84fb8dc1f05a18064f8cad6ab0..c23c1f48c967e2bbadb44f10cc8971c654932b1a 100644 (file)
@@ -3,5 +3,16 @@
 #define __NVKM_NVDEC_PRIV_H__
 #include <engine/nvdec.h>
 
-int nvkm_nvdec_new_(struct nvkm_device *, int, struct nvkm_nvdec **);
+struct nvkm_nvdec_func {
+};
+
+struct nvkm_nvdec_fwif {
+       int version;
+       int (*load)(struct nvkm_nvdec *, int ver,
+                   const struct nvkm_nvdec_fwif *);
+       const struct nvkm_nvdec_func *func;
+};
+
+int nvkm_nvdec_new_(const struct nvkm_nvdec_fwif *fwif,
+                   struct nvkm_device *, int, struct nvkm_nvdec **);
 #endif