Commit 98a34d99 authored by Ben Skeggs's avatar Ben Skeggs
Browse files

drm/nouveau/nvdec: select implementation based on available fw



This will allow for further customisation of the subdev depending on what
firmware is available.

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent c9af47bc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include <core/engine.h>

struct nvkm_nvdec {
	const struct nvkm_nvdec_func *func;
	struct nvkm_engine engine;
	u32 addr;

+15 −4
Original line number Diff line number Diff line
@@ -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,
	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;
};
+18 −2
Original line number Diff line number Diff line
@@ -19,12 +19,28 @@
 * 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);
}
+12 −1
Original line number Diff line number Diff line
@@ -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