[PATCH 107/156] drm/nouveau/nvif: rework outp "edid get" api

Ben Skeggs bskeggs at nvidia.com
Tue Apr 16 23:39:13 UTC 2024


- transition from "ioctl" interface

Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
 .../gpu/drm/nouveau/include/nvif/driverif.h   |  1 +
 drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----------
 drivers/gpu/drm/nouveau/nvif/outp.c           | 19 +++++++++----------
 .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c  | 19 +++++++++----------
 4 files changed, 19 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index fd05065374fe..966a9bb543d1 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -274,6 +274,7 @@ struct nvif_outp_impl {
 	u8 conn;
 
 	int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
+	int (*edid_get)(struct nvif_outp_priv *, u8 *data, u16 *size);
 
 	struct {
 		u32 freq_max;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index c0c13cb64994..80c4da3e8aa5 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,8 +4,6 @@
 
 #include <drm/display/drm_dp.h>
 
-#define NVIF_OUTP_V0_EDID_GET      0x01
-
 #define NVIF_OUTP_V0_INHERIT       0x10
 #define NVIF_OUTP_V0_ACQUIRE       0x11
 #define NVIF_OUTP_V0_RELEASE       0x12
@@ -32,15 +30,6 @@
 #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
 #define NVIF_OUTP_V0_DP_MST_VCPI   0x78
 
-union nvif_outp_edid_get_args {
-	struct nvif_outp_edid_get_v0 {
-		__u8  version;
-		__u8  pad01;
-		__u16 size;
-		__u8  data[2048];
-	} v0;
-};
-
 union nvif_outp_load_detect_args {
 	struct nvif_outp_load_detect_v0 {
 		__u8  version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index b704886c1bb6..56441763e3da 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -438,29 +438,28 @@ nvif_outp_load_detect(struct nvif_outp *outp, u32 loadval)
 int
 nvif_outp_edid_get(struct nvif_outp *outp, u8 **pedid)
 {
-	struct nvif_outp_edid_get_v0 *args;
+	u16 size = 2048;
+	u8 *data;
 	int ret;
 
-	args = kmalloc(sizeof(*args), GFP_KERNEL);
-	if (!args)
+	data = kmalloc(size, GFP_KERNEL);
+	if (!data)
 		return -ENOMEM;
 
-	args->version = 0;
-
-	ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_EDID_GET, args, sizeof(*args));
-	NVIF_ERRON(ret, &outp->object, "[EDID_GET] size:%d", args->size);
+	ret = outp->impl->edid_get(outp->priv, data, &size);
+	NVIF_ERRON(ret, &outp->object, "[EDID_GET] size:%d", size);
 	if (ret)
 		goto done;
 
-	*pedid = kmemdup(args->data, args->size, GFP_KERNEL);
+	*pedid = kmemdup(data, size, GFP_KERNEL);
 	if (!*pedid) {
 		ret = -ENOMEM;
 		goto done;
 	}
 
-	ret = args->size;
+	ret = size;
 done:
-	kfree(args);
+	kfree(data);
 	return ret;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 2324549787b6..37521fa2cbfe 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -491,17 +491,15 @@ nvkm_uoutp_mthd_load_detect(struct nvkm_outp *outp, void *argv, u32 argc)
 }
 
 static int
-nvkm_uoutp_mthd_edid_get(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_edid_get(struct nvif_outp_priv *uoutp, u8 *data, u16 *size)
 {
-	union nvif_outp_edid_get_args *args = argv;
-
-	if (argc != sizeof(args->v0) || args->v0.version != 0)
-		return -ENOSYS;
-	if (!outp->func->edid_get)
-		return -EINVAL;
+	struct nvkm_outp *outp = uoutp->outp;
+	int ret;
 
-	args->v0.size = ARRAY_SIZE(args->v0.data);
-	return outp->func->edid_get(outp, args->v0.data, &args->v0.size);
+	nvkm_uoutp_lock(uoutp);
+	ret = outp->func->edid_get(outp, data, size);
+	nvkm_uoutp_unlock(uoutp);
+	return ret;
 }
 
 static int
@@ -551,7 +549,6 @@ static int
 nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc, bool *invalid)
 {
 	switch (mthd) {
-	case NVIF_OUTP_V0_EDID_GET   : return nvkm_uoutp_mthd_edid_get   (outp, argv, argc);
 	case NVIF_OUTP_V0_INHERIT    : return nvkm_uoutp_mthd_inherit    (outp, argv, argc);
 	case NVIF_OUTP_V0_ACQUIRE    : return nvkm_uoutp_mthd_acquire    (outp, argv, argc);
 	case NVIF_OUTP_V0_LOAD_DETECT: return nvkm_uoutp_mthd_load_detect(outp, argv, argc);
@@ -651,6 +648,8 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
 
 	if (outp->func->detect)
 		uoutp->impl.detect = nvkm_uoutp_detect;
+	if (outp->func->edid_get)
+		uoutp->impl.edid_get = nvkm_uoutp_edid_get;
 
 	switch (outp->info.type) {
 	case DCB_OUTPUT_ANALOG:
-- 
2.41.0



More information about the Nouveau mailing list