[PATCH 108/156] drm/nouveau/nvif: rework outp "load detect" api
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:39:14 UTC 2024
- transition from "ioctl" interface
Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
drivers/gpu/drm/nouveau/include/nvif/driverif.h | 2 ++
drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----------
drivers/gpu/drm/nouveau/nvif/outp.c | 11 ++++-------
drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 15 ++++++++-------
4 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 966a9bb543d1..39b0e8d002f8 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -276,6 +276,8 @@ struct nvif_outp_impl {
int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *);
int (*edid_get)(struct nvif_outp_priv *, u8 *data, u16 *size);
+ int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
+
struct {
u32 freq_max;
} rgb_crt;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 80c4da3e8aa5..586b44fa8814 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -8,8 +8,6 @@
#define NVIF_OUTP_V0_ACQUIRE 0x11
#define NVIF_OUTP_V0_RELEASE 0x12
-#define NVIF_OUTP_V0_LOAD_DETECT 0x20
-
#define NVIF_OUTP_V0_BL_GET 0x30
#define NVIF_OUTP_V0_BL_SET 0x31
@@ -30,15 +28,6 @@
#define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
#define NVIF_OUTP_V0_DP_MST_VCPI 0x78
-union nvif_outp_load_detect_args {
- struct nvif_outp_load_detect_v0 {
- __u8 version;
- __u8 load;
- __u8 pad02[2];
- __u32 data; /*TODO: move vbios loadval parsing into nvkm */
- } v0;
-};
-
union nvif_outp_acquire_args {
struct nvif_outp_acquire_v0 {
__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 56441763e3da..59499eebc5ac 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -424,15 +424,12 @@ nvif_outp_inherit_rgb_crt(struct nvif_outp *outp, u8 *proto_out)
int
nvif_outp_load_detect(struct nvif_outp *outp, u32 loadval)
{
- struct nvif_outp_load_detect_v0 args;
+ u8 load;
int ret;
- args.version = 0;
- args.data = loadval;
-
- ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_LOAD_DETECT, &args, sizeof(args));
- NVIF_ERRON(ret, &outp->object, "[LOAD_DETECT data:%08x] load:%02x", args.data, args.load);
- return ret < 0 ? ret : args.load;
+ ret = outp->impl->load_detect(outp->priv, loadval, &load);
+ NVIF_ERRON(ret, &outp->object, "[LOAD_DETECT data:%08x] load:%02x", loadval, load);
+ return ret < 0 ? ret : load;
}
int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index 37521fa2cbfe..d3f69d6a10f3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -468,25 +468,25 @@ nvkm_uoutp_mthd_inherit(struct nvkm_outp *outp, void *argv, u32 argc)
}
static int
-nvkm_uoutp_mthd_load_detect(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_load_detect(struct nvif_outp_priv *uoutp, u32 loadval, u8 *load)
{
- union nvif_outp_load_detect_args *args = argv;
+ struct nvkm_outp *outp = uoutp->outp;
int ret;
- if (argc != sizeof(args->v0) || args->v0.version != 0)
- return -ENOSYS;
+ nvkm_uoutp_lock(uoutp);
ret = nvkm_outp_acquire_or(outp, NVKM_OUTP_PRIV, false);
if (ret == 0) {
if (outp->ior->func->sense) {
- ret = outp->ior->func->sense(outp->ior, args->v0.data);
- args->v0.load = ret < 0 ? 0 : ret;
+ ret = outp->ior->func->sense(outp->ior, loadval);
+ *load = ret < 0 ? 0 : ret;
} else {
ret = -EINVAL;
}
nvkm_outp_release_or(outp, NVKM_OUTP_PRIV);
}
+ nvkm_uoutp_unlock(uoutp);
return ret;
}
@@ -551,7 +551,6 @@ nvkm_uoutp_mthd_noacquire(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc
switch (mthd) {
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);
case NVIF_OUTP_V0_BL_GET : return nvkm_uoutp_mthd_bl_get (outp, argv, argc);
case NVIF_OUTP_V0_BL_SET : return nvkm_uoutp_mthd_bl_set (outp, argv, argc);
case NVIF_OUTP_V0_DP_AUX_PWR : return nvkm_uoutp_mthd_dp_aux_pwr (outp, argv, argc);
@@ -651,6 +650,8 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
if (outp->func->edid_get)
uoutp->impl.edid_get = nvkm_uoutp_edid_get;
+ uoutp->impl.load_detect = nvkm_uoutp_load_detect;
+
switch (outp->info.type) {
case DCB_OUTPUT_ANALOG:
uoutp->impl.type = NVIF_OUTP_DAC;
--
2.41.0
More information about the Nouveau
mailing list