[PATCH 114/156] drm/nouveau/nvif: rework outp "hdmi config" api
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:39:20 UTC 2024
- transition from "ioctl" interface
Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
.../gpu/drm/nouveau/include/nvif/driverif.h | 6 +++
drivers/gpu/drm/nouveau/include/nvif/if0012.h | 16 -------
drivers/gpu/drm/nouveau/nvif/outp.c | 18 ++-----
.../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 47 ++++++++++++-------
4 files changed, 39 insertions(+), 48 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 1eec40976a70..6f1ec831b4d7 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -291,6 +291,12 @@ struct nvif_outp_impl {
u8 dual;
} tmds;
+ struct {
+ int (*config)(struct nvif_outp_priv *, u8 head, bool enable, u8 max_ac_packet,
+ u8 rekey, u32 khz, bool scdc, bool scdc_scrambling,
+ bool scdc_low_rates);
+ } hdmi;
+
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 d8c6e84cf5ae..c2a3af721116 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_HDMI 0x50
-
#define NVIF_OUTP_V0_INFOFRAME 0x60
#define NVIF_OUTP_V0_HDA_ELD 0x61
@@ -19,20 +17,6 @@
#define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77
#define NVIF_OUTP_V0_DP_MST_VCPI 0x78
-union nvif_outp_hdmi_args {
- struct nvif_outp_hdmi_v0 {
- __u8 version;
- __u8 head;
- __u8 enable;
- __u8 max_ac_packet;
- __u8 rekey;
- __u8 scdc;
- __u8 scdc_scrambling;
- __u8 scdc_low_rates;
- __u32 khz;
- } v0;
-};
-
union nvif_outp_infoframe_args {
struct nvif_outp_infoframe_v0 {
__u8 version;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index edcb5598efac..99a1e0073166 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -229,25 +229,15 @@ int
nvif_outp_hdmi(struct nvif_outp *outp, int head, bool enable, u8 max_ac_packet, u8 rekey,
u32 khz, bool scdc, bool scdc_scrambling, bool scdc_low_rates)
{
- struct nvif_outp_hdmi_v0 args;
int ret;
- args.version = 0;
- args.head = head;
- args.enable = enable;
- args.max_ac_packet = max_ac_packet;
- args.rekey = rekey;
- args.khz = khz;
- args.scdc = scdc;
- args.scdc_scrambling = scdc_scrambling;
- args.scdc_low_rates = scdc_low_rates;
-
- ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_HDMI, &args, sizeof(args));
+ ret = outp->impl->hdmi.config(outp->priv, head, enable, max_ac_packet, rekey, khz,
+ scdc, scdc_scrambling, scdc_low_rates);
NVIF_ERRON(ret, &outp->object,
"[HDMI head:%d enable:%d max_ac_packet:%d rekey:%d khz:%d scdc:%d "
"scdc_scrambling:%d scdc_low_rates:%d]",
- args.head, args.enable, args.max_ac_packet, args.rekey, args.khz,
- args.scdc, args.scdc_scrambling, args.scdc_low_rates);
+ head, enable, max_ac_packet, rekey, khz,
+ scdc, scdc_scrambling, scdc_low_rates);
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 93de3990554e..325af91075ab 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -271,36 +271,47 @@ nvkm_uoutp_mthd_infoframe(struct nvkm_outp *outp, void *argv, u32 argc)
}
static int
-nvkm_uoutp_mthd_hdmi(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_hdmi(struct nvif_outp_priv *uoutp, u8 head, bool enable, u8 max_ac_packet, u8 rekey,
+ u32 khz, bool scdc, bool scdc_scrambling, bool scdc_low_rates)
{
- union nvif_outp_hdmi_args *args = argv;
- struct nvkm_ior *ior = outp->ior;
+ struct nvkm_outp *outp = uoutp->outp;
+ struct nvkm_ior *ior;
+ int ret;
- if (argc != sizeof(args->v0) || args->v0.version != 0)
- return -ENOSYS;
+ ret = nvkm_uoutp_lock_acquired(uoutp);
+ if (ret)
+ return ret;
- if (!(outp->asy.head = nvkm_head_find(outp->disp, args->v0.head)))
+ if (!(outp->asy.head = nvkm_head_find(outp->disp, head))) {
+ nvkm_uoutp_unlock(uoutp);
return -EINVAL;
+ }
+
+ ior = outp->ior;
if (!ior->func->hdmi ||
- args->v0.max_ac_packet > 0x1f ||
- args->v0.rekey > 0x7f ||
- (args->v0.scdc && !ior->func->hdmi->scdc))
+ max_ac_packet > 0x1f ||
+ rekey > 0x7f ||
+ (scdc && !ior->func->hdmi->scdc)) {
+ nvkm_uoutp_unlock(uoutp);
return -EINVAL;
+ }
- if (!args->v0.enable) {
- ior->func->hdmi->infoframe_avi(ior, args->v0.head, NULL, 0);
- ior->func->hdmi->infoframe_vsi(ior, args->v0.head, NULL, 0);
- ior->func->hdmi->ctrl(ior, args->v0.head, false, 0, 0);
+ if (!enable) {
+ ior->func->hdmi->infoframe_avi(ior, head, NULL, 0);
+ ior->func->hdmi->infoframe_vsi(ior, head, NULL, 0);
+ ior->func->hdmi->ctrl(ior, head, false, 0, 0);
+ nvkm_uoutp_unlock(uoutp);
return 0;
}
- ior->func->hdmi->ctrl(ior, args->v0.head, args->v0.enable,
- args->v0.max_ac_packet, args->v0.rekey);
+ ior->func->hdmi->ctrl(ior, head, enable,
+ max_ac_packet, rekey);
if (ior->func->hdmi->scdc)
- ior->func->hdmi->scdc(ior, args->v0.khz, args->v0.scdc, args->v0.scdc_scrambling,
- args->v0.scdc_low_rates);
+ ior->func->hdmi->scdc(ior, khz, scdc, scdc_scrambling,
+ scdc_low_rates);
+ nvkm_uoutp_unlock(uoutp);
return 0;
}
@@ -522,7 +533,6 @@ static int
nvkm_uoutp_mthd_acquired(struct nvkm_outp *outp, u32 mthd, void *argv, u32 argc)
{
switch (mthd) {
- case NVIF_OUTP_V0_HDMI : return nvkm_uoutp_mthd_hdmi (outp, argv, argc);
case NVIF_OUTP_V0_INFOFRAME : return nvkm_uoutp_mthd_infoframe (outp, argv, argc);
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);
@@ -659,6 +669,7 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp
uoutp->impl.tmds.dual = 0;
}
uoutp->impl.proto = NVIF_OUTP_TMDS;
+ uoutp->impl.hdmi.config = nvkm_uoutp_hdmi;
break;
case DCB_OUTPUT_LVDS:
uoutp->impl.type = NVIF_OUTP_SOR;
--
2.41.0
More information about the Nouveau
mailing list