Commit 168c0299 authored by Ben Skeggs's avatar Ben Skeggs Committed by Dave Airlie
Browse files

drm/nouveau/disp: add common class handling between <nv50 and >=nv50



About to expose head/output path/connector objects everywhere, so we will
need support for child classes prior to nv50 now.

Somewhat cleaner than the code >=nv50 used previously.

v2:
- use ?: (lyude)

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 92fba5d3
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@
#define NVIF_CLASS_VMM_GM200                         /* ifb00d.h */  0x8000b00d
#define NVIF_CLASS_VMM_GP100                         /* ifc00d.h */  0x8000c00d

#define NVIF_CLASS_DISP                              /* if0010.h */  0x80000010

/* the below match nvidia-assigned (either in hw, or sw) class numbers */
#define NV_NULL_CLASS                                                0x00000030

@@ -73,21 +75,21 @@
#define TURING_CHANNEL_GPFIFO_A                       /* clc36f.h */ 0x0000c46f
#define AMPERE_CHANNEL_GPFIFO_B                       /* clc36f.h */ 0x0000c76f

#define NV50_DISP                                     /* cl5070.h */ 0x00005070
#define G82_DISP                                      /* cl5070.h */ 0x00008270
#define GT200_DISP                                    /* cl5070.h */ 0x00008370
#define GT214_DISP                                    /* cl5070.h */ 0x00008570
#define GT206_DISP                                    /* cl5070.h */ 0x00008870
#define GF110_DISP                                    /* cl5070.h */ 0x00009070
#define GK104_DISP                                    /* cl5070.h */ 0x00009170
#define GK110_DISP                                    /* cl5070.h */ 0x00009270
#define GM107_DISP                                    /* cl5070.h */ 0x00009470
#define GM200_DISP                                    /* cl5070.h */ 0x00009570
#define GP100_DISP                                    /* cl5070.h */ 0x00009770
#define GP102_DISP                                    /* cl5070.h */ 0x00009870
#define GV100_DISP                                    /* cl5070.h */ 0x0000c370
#define TU102_DISP                                    /* cl5070.h */ 0x0000c570
#define GA102_DISP                                    /* cl5070.h */ 0x0000c670
#define NV50_DISP                                     /* if0010.h */ 0x00005070
#define G82_DISP                                      /* if0010.h */ 0x00008270
#define GT200_DISP                                    /* if0010.h */ 0x00008370
#define GT214_DISP                                    /* if0010.h */ 0x00008570
#define GT206_DISP                                    /* if0010.h */ 0x00008870
#define GF110_DISP                                    /* if0010.h */ 0x00009070
#define GK104_DISP                                    /* if0010.h */ 0x00009170
#define GK110_DISP                                    /* if0010.h */ 0x00009270
#define GM107_DISP                                    /* if0010.h */ 0x00009470
#define GM200_DISP                                    /* if0010.h */ 0x00009570
#define GP100_DISP                                    /* if0010.h */ 0x00009770
#define GP102_DISP                                    /* if0010.h */ 0x00009870
#define GV100_DISP                                    /* if0010.h */ 0x0000c370
#define TU102_DISP                                    /* if0010.h */ 0x0000c570
#define GA102_DISP                                    /* if0010.h */ 0x0000c670

#define GV100_DISP_CAPS                                              0x0000c373

+11 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: MIT */
#ifndef __NVIF_IF0010_H__
#define __NVIF_IF0010_H__

union nvif_disp_args {
	struct nvif_disp_v0 {
		__u8 version;
		__u8 pad01[7];
	} v0;
};
#endif
+9 −0
Original line number Diff line number Diff line
@@ -17,4 +17,13 @@
#endif

#define NVIF_ERROR(o,f,a...) NVIF_PRINT(errorf, (o), f, ##a)
#define NVIF_ERRON(c,o,f,a...) do {                            \
	struct nvif_object *_object = (o);                     \
	int _cond = (c);                                       \
	if (_cond) {                                           \
		NVIF_ERROR(_object, f" (ret:%d)", ##a, _cond); \
	} else {                                               \
		NVIF_DEBUG(_object, f, ##a);                   \
	}                                                      \
} while(0)
#endif
+2 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
#define __NVKM_DISP_H__
#define nvkm_disp(p) container_of((p), struct nvkm_disp, engine)
#include <core/engine.h>
#include <core/object.h>
#include <core/event.h>

struct nvkm_disp {
@@ -47,7 +48,7 @@ struct nvkm_disp {

	struct {
		spinlock_t lock;
		struct nvkm_oproxy *object;
		struct nvkm_object object;
	} client;
};

+32 −22
Original line number Diff line number Diff line
@@ -21,8 +21,10 @@
 */
#include <nvif/disp.h>
#include <nvif/device.h>
#include <nvif/printf.h>

#include <nvif/class.h>
#include <nvif/if0010.h>

void
nvif_disp_dtor(struct nvif_disp *disp)
@@ -31,33 +33,41 @@ nvif_disp_dtor(struct nvif_disp *disp)
}

int
nvif_disp_ctor(struct nvif_device *device, const char *name, s32 oclass,
	       struct nvif_disp *disp)
nvif_disp_ctor(struct nvif_device *device, const char *name, s32 oclass, struct nvif_disp *disp)
{
	static const struct nvif_mclass disps[] = {
		{ GA102_DISP, -1 },
		{ TU102_DISP, -1 },
		{ GV100_DISP, -1 },
		{ GP102_DISP, -1 },
		{ GP100_DISP, -1 },
		{ GM200_DISP, -1 },
		{ GM107_DISP, -1 },
		{ GK110_DISP, -1 },
		{ GK104_DISP, -1 },
		{ GF110_DISP, -1 },
		{ GT214_DISP, -1 },
		{ GT206_DISP, -1 },
		{ GT200_DISP, -1 },
		{   G82_DISP, -1 },
		{  NV50_DISP, -1 },
		{  NV04_DISP, -1 },
		{ GA102_DISP, 0 },
		{ TU102_DISP, 0 },
		{ GV100_DISP, 0 },
		{ GP102_DISP, 0 },
		{ GP100_DISP, 0 },
		{ GM200_DISP, 0 },
		{ GM107_DISP, 0 },
		{ GK110_DISP, 0 },
		{ GK104_DISP, 0 },
		{ GF110_DISP, 0 },
		{ GT214_DISP, 0 },
		{ GT206_DISP, 0 },
		{ GT200_DISP, 0 },
		{   G82_DISP, 0 },
		{  NV50_DISP, 0 },
		{  NV04_DISP, 0 },
		{}
	};
	int cid = nvif_sclass(&device->object, disps, oclass);
	struct nvif_disp_v0 args;
	int cid, ret;

	cid = nvif_sclass(&device->object, disps, oclass);
	disp->object.client = NULL;
	if (cid < 0)
	if (cid < 0) {
		NVIF_ERRON(cid, &device->object, "[NEW disp%04x] not supported", oclass);
		return cid;
	}

	args.version = 0;

	return nvif_object_ctor(&device->object, name ? name : "nvifDisp", 0,
				disps[cid].oclass, NULL, 0, &disp->object);
	ret = nvif_object_ctor(&device->object, name ?: "nvifDisp", 0,
			       disps[cid].oclass, &args, sizeof(args), &disp->object);
	NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", disps[cid].oclass);
	return ret;
}
Loading