[PATCH 116/156] drm/nouveau/nvif: rework outp "hda eld" api
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:39:22 UTC 2024
- transition from "ioctl" interface
Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
.../gpu/drm/nouveau/include/nvif/driverif.h | 4 ++
drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 -----
drivers/gpu/drm/nouveau/nvif/outp.c | 13 +-----
.../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 45 +++++++++++--------
4 files changed, 32 insertions(+), 41 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index cef19e04f208..742cf0e1678b 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -304,6 +304,10 @@ struct nvif_outp_impl {
u8 *data, u8 size);
} hdmi;
+ struct {
+ int (*eld)(struct nvif_outp_priv *, u8 head, u8 *data, u8 size);
+ } hda;
+
struct {
u8 acpi_edid;
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index a045c66fc1ca..160387dfc2a0 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_HDA_ELD 0x61
-
#define NVIF_OUTP_V0_DP_AUX_PWR 0x70
#define NVIF_OUTP_V0_DP_AUX_XFER 0x71
#define NVIF_OUTP_V0_DP_RATES 0x72
@@ -16,15 +14,6 @@
#define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
#define NVIF_OUTP_V0_DP_MST_VCPI 0x78
-union nvif_outp_hda_eld_args {
- struct nvif_outp_hda_eld_v0 {
- __u8 version;
- __u8 head;
- __u8 pad02[6];
- __u8 data[];
- } v0;
-};
-
union nvif_outp_dp_aux_pwr_args {
struct nvif_outp_dp_aux_pwr_v0 {
__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 4ecdc44eb84a..cf79c56aae0c 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -195,20 +195,9 @@ nvif_outp_dp_aux_pwr(struct nvif_outp *outp, bool enable)
int
nvif_outp_hda_eld(struct nvif_outp *outp, int head, void *data, u32 size)
{
- struct {
- struct nvif_outp_hda_eld_v0 mthd;
- u8 data[128];
- } args;
int ret;
- if (WARN_ON(size > ARRAY_SIZE(args.data)))
- return -EINVAL;
-
- args.mthd.version = 0;
- args.mthd.head = head;
-
- memcpy(args.data, data, size);
- ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_HDA_ELD, &args, sizeof(args.mthd) + size);
+ ret = outp->impl->hda.eld(outp->priv, head, data, size);
NVIF_ERRON(ret, &outp->object, "[HDA_ELD head:%d size:%d]", head, size);
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 a694a43fd495..7184f13f39f5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -208,39 +208,47 @@ nvkm_uoutp_mthd_dp_aux_pwr(struct nvkm_outp *outp, void *argv, u32 argc)
}
static int
-nvkm_uoutp_mthd_hda_eld(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_hda_eld(struct nvif_outp_priv *uoutp, u8 head, u8 *data, u8 size)
{
- struct nvkm_ior *ior = outp->ior;
- union nvif_outp_hda_eld_args *args = argv;
-
- if (argc < sizeof(args->v0) || args->v0.version != 0)
- return -ENOSYS;
- argc -= sizeof(args->v0);
+ struct nvkm_outp *outp = uoutp->outp;
+ struct nvkm_ior *ior;
+ int ret;
- if (!ior->hda || !nvkm_head_find(outp->disp, args->v0.head))
+ if (!nvkm_head_find(outp->disp, head))
return -EINVAL;
- if (argc > 0x60)
+ if (size > 0x60)
return -E2BIG;
- if (argc && args->v0.data[0]) {
+ ret = nvkm_uoutp_lock_acquired(uoutp);
+ if (ret)
+ return ret;
+
+ ior = outp->ior;
+ if (!ior->hda) {
+ nvkm_uoutp_unlock(uoutp);
+ return -EINVAL;
+ }
+
+ if (size && data[0]) {
if (outp->info.type == DCB_OUTPUT_DP)
- ior->func->dp->audio(ior, args->v0.head, true);
+ ior->func->dp->audio(ior, head, true);
else
if (ior->func->hdmi->audio)
- ior->func->hdmi->audio(ior, args->v0.head, true);
+ ior->func->hdmi->audio(ior, head, true);
- ior->func->hda->hpd(ior, args->v0.head, true);
- ior->func->hda->eld(ior, args->v0.head, args->v0.data, argc);
+ ior->func->hda->hpd(ior, head, true);
+ ior->func->hda->eld(ior, head, data, size);
} else {
- ior->func->hda->hpd(ior, args->v0.head, false);
+ ior->func->hda->hpd(ior, head, false);
if (outp->info.type == DCB_OUTPUT_DP)
- ior->func->dp->audio(ior, args->v0.head, false);
+ ior->func->dp->audio(ior, head, false);
else
if (ior->func->hdmi->audio)
- ior->func->hdmi->audio(ior, args->v0.head, false);
+ ior->func->hdmi->audio(ior, head, false);
}
+ nvkm_uoutp_unlock(uoutp);
return 0;
}
@@ -539,7 +547,6 @@ static int
nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
{
switch (mthd) {
- case NVIF_OUTP_V0_HDA_ELD : return nvkm_uoutp_mthd_hda_eld (outp, argv, argc);
case NVIF_OUTP_V0_DP_TRAIN : return nvkm_uoutp_mthd_dp_train (outp, argv, argc);
case NVIF_OUTP_V0_DP_DRIVE : return nvkm_uoutp_mthd_dp_drive (outp, argv, argc);
case NVIF_OUTP_V0_DP_SST : return nvkm_uoutp_mthd_dp_sst (outp, argv, argc);
@@ -676,6 +683,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
uoutp->impl.proto = NVIF_OUTP_TMDS;
uoutp->impl.hdmi.config = nvkm_uoutp_hdmi;
uoutp->impl.hdmi.infoframe = nvkm_uoutp_infoframe;
+ uoutp->impl.hda.eld = nvkm_uoutp_hda_eld;
break;
case DCB_OUTPUT_LVDS:
uoutp->impl.type = NVIF_OUTP_SOR;
@@ -692,6 +700,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
uoutp->impl.dp.aux = NVKM_I2C_AUX_EXT(outp->info.extdev);
}
uoutp->impl.proto = NVIF_OUTP_DP;
+ uoutp->impl.hda.eld = nvkm_uoutp_hda_eld;
uoutp->impl.dp.mst = outp->dp.mst;
uoutp->impl.dp.increased_wm = outp->dp.increased_wm;
uoutp->impl.dp.link_nr = outp->info.dpconf.link_nr;
--
2.41.0
More information about the Nouveau
mailing list