[PATCH 109/156] drm/nouveau/nvif: rework outp "inherit" apis
Ben Skeggs
bskeggs at nvidia.com
Tue Apr 16 23:39:15 UTC 2024
- transition from "ioctl" interfaces
Signed-off-by: Ben Skeggs <bskeggs at nvidia.com>
---
.../gpu/drm/nouveau/include/nvif/driverif.h | 3 ++
drivers/gpu/drm/nouveau/include/nvif/if0012.h | 23 ---------
drivers/gpu/drm/nouveau/nvif/outp.c | 40 +++++++--------
.../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 50 +++++++++----------
4 files changed, 45 insertions(+), 71 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
index 39b0e8d002f8..9ab54de43ba3 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h
@@ -276,6 +276,9 @@ 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 (*inherit)(struct nvif_outp_priv *, enum nvif_outp_proto,
+ u8 *or, u8 *link, u8 *head, u8 *proto_evo);
+
int (*load_detect)(struct nvif_outp_priv *, u32 loadval, u8 *load);
struct {
diff --git a/drivers/gpu/drm/nouveau/include/nvif/if0012.h b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
index 586b44fa8814..09e2f61673a8 100644
--- a/drivers/gpu/drm/nouveau/include/nvif/if0012.h
+++ b/drivers/gpu/drm/nouveau/include/nvif/if0012.h
@@ -4,7 +4,6 @@
#include <drm/display/drm_dp.h>
-#define NVIF_OUTP_V0_INHERIT 0x10
#define NVIF_OUTP_V0_ACQUIRE 0x11
#define NVIF_OUTP_V0_RELEASE 0x12
@@ -46,28 +45,6 @@ union nvif_outp_acquire_args {
} v0;
};
-union nvif_outp_inherit_args {
- struct nvif_outp_inherit_v0 {
- __u8 version;
-#define NVIF_OUTP_INHERIT_V0_RGB_CRT 0x00
-#define NVIF_OUTP_INHERIT_V0_TV 0x01
-#define NVIF_OUTP_INHERIT_V0_TMDS 0x02
-#define NVIF_OUTP_INHERIT_V0_LVDS 0x03
-#define NVIF_OUTP_INHERIT_V0_DP 0x04
- // In/out. Input is one of the above values, output is the actual hw protocol
- __u8 proto;
- __u8 or;
- __u8 link;
- __u8 head;
- union {
- struct {
- // TODO: Figure out padding, and whether we even want this field
- __u8 hda;
- } tmds;
- };
- } v0;
-};
-
union nvif_outp_release_args {
struct nvif_outp_release_vn {
} vn;
diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c
index 59499eebc5ac..c98af48b4b33 100644
--- a/drivers/gpu/drm/nouveau/nvif/outp.c
+++ b/drivers/gpu/drm/nouveau/nvif/outp.c
@@ -354,71 +354,65 @@ nvif_outp_acquire_dac(struct nvif_outp *outp)
}
static int
-nvif_outp_inherit(struct nvif_outp *outp,
- u8 proto,
- struct nvif_outp_inherit_v0 *args,
- u8 *proto_out)
+nvif_outp_inherit(struct nvif_outp *outp, enum nvif_outp_proto proto, u8 *head, u8 *proto_evo)
{
+ u8 or, link;
int ret;
- args->version = 0;
- args->proto = proto;
-
- ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_INHERIT, args, sizeof(*args));
+ ret = outp->impl->inherit(outp->priv, proto, &or, &link, head, proto_evo);
if (ret)
return ret;
- outp->or.id = args->or;
- outp->or.link = args->link;
- *proto_out = args->proto;
+ outp->or.id = or;
+ outp->or.link = link;
return 0;
}
int
nvif_outp_inherit_lvds(struct nvif_outp *outp, u8 *proto_out)
{
- struct nvif_outp_inherit_v0 args;
+ u8 head;
int ret;
- ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_LVDS, &args, proto_out);
+ ret = nvif_outp_inherit(outp, NVIF_OUTP_LVDS, &head, proto_out);
NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:LVDS] ret:%d", ret);
- return ret ?: args.head;
+ return ret ?: head;
}
int
nvif_outp_inherit_tmds(struct nvif_outp *outp, u8 *proto_out)
{
- struct nvif_outp_inherit_v0 args;
+ u8 head;
int ret;
- ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_TMDS, &args, proto_out);
+ ret = nvif_outp_inherit(outp, NVIF_OUTP_TMDS, &head, proto_out);
NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:TMDS] ret:%d", ret);
- return ret ?: args.head;
+ return ret ?: head;
}
int
nvif_outp_inherit_dp(struct nvif_outp *outp, u8 *proto_out)
{
- struct nvif_outp_inherit_v0 args;
+ u8 head;
int ret;
- ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_DP, &args, proto_out);
+ ret = nvif_outp_inherit(outp, NVIF_OUTP_DP, &head, proto_out);
NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:DP] ret:%d", ret);
// TODO: Get current link info
- return ret ?: args.head;
+ return ret ?: head;
}
int
nvif_outp_inherit_rgb_crt(struct nvif_outp *outp, u8 *proto_out)
{
- struct nvif_outp_inherit_v0 args;
+ u8 head;
int ret;
- ret = nvif_outp_inherit(outp, NVIF_OUTP_INHERIT_V0_RGB_CRT, &args, proto_out);
+ ret = nvif_outp_inherit(outp, NVIF_OUTP_RGB_CRT, &head, proto_out);
NVIF_ERRON(ret && ret != -ENODEV, &outp->object, "[INHERIT proto:RGB_CRT] ret:%d", ret);
- return ret ?: args.head;
+ return ret ?: head;
}
int
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
index d3f69d6a10f3..3f242a03f77b 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c
@@ -405,44 +405,40 @@ nvkm_uoutp_mthd_acquire(struct nvkm_outp *outp, void *argv, u32 argc)
}
static int
-nvkm_uoutp_mthd_inherit(struct nvkm_outp *outp, void *argv, u32 argc)
+nvkm_uoutp_inherit(struct nvif_outp_priv *uoutp, enum nvif_outp_proto proto,
+ u8 *or, u8 *link, u8 *head, u8 *proto_evo)
{
- union nvif_outp_inherit_args *args = argv;
+ struct nvkm_outp *outp = uoutp->outp;
struct nvkm_ior *ior;
- int ret = 0;
+ int ret = -ENODEV;
- if (argc != sizeof(args->v0) || args->v0.version != 0)
- return -ENOSYS;
+ nvkm_uoutp_lock(uoutp);
/* Ensure an ior is hooked up to this outp already */
ior = outp->func->inherit(outp);
if (!ior || !ior->arm.head)
- return -ENODEV;
+ goto done;
/* With iors, there will be a separate output path for each type of connector - and all of
* them will appear to be hooked up. Figure out which one is actually the one we're using
* based on the protocol we were given over nvif
*/
- switch (args->v0.proto) {
- case NVIF_OUTP_INHERIT_V0_TMDS:
+ switch (proto) {
+ case NVIF_OUTP_TMDS:
if (ior->arm.proto != TMDS)
- return -ENODEV;
+ goto done;
break;
- case NVIF_OUTP_INHERIT_V0_DP:
+ case NVIF_OUTP_DP:
if (ior->arm.proto != DP)
- return -ENODEV;
+ goto done;
break;
- case NVIF_OUTP_INHERIT_V0_LVDS:
+ case NVIF_OUTP_LVDS:
if (ior->arm.proto != LVDS)
- return -ENODEV;
+ goto done;
break;
- case NVIF_OUTP_INHERIT_V0_TV:
- if (ior->arm.proto != TV)
- return -ENODEV;
- break;
- case NVIF_OUTP_INHERIT_V0_RGB_CRT:
+ case NVIF_OUTP_RGB_CRT:
if (ior->arm.proto != CRT)
- return -ENODEV;
+ goto done;
break;
default:
ret = -EINVAL;
@@ -452,18 +448,22 @@ nvkm_uoutp_mthd_inherit(struct nvkm_outp *outp, void *argv, u32 argc)
/* Make sure that userspace hasn't already acquired this */
if (outp->acquired) {
OUTP_ERR(outp, "cannot inherit an already acquired (%02x) outp", outp->acquired);
- return -EBUSY;
+ ret = -EBUSY;
+ goto done;
}
/* Mark the outp acquired by userspace now that we've confirmed it's already active */
OUTP_TRACE(outp, "inherit %02x |= %02x %p", outp->acquired, NVKM_OUTP_USER, ior);
nvkm_outp_acquire_ior(outp, NVKM_OUTP_USER, ior);
- args->v0.or = ior->id;
- args->v0.link = ior->arm.link;
- args->v0.head = ffs(ior->arm.head) - 1;
- args->v0.proto = ior->arm.proto_evo;
+ *or = ior->id;
+ *link = ior->arm.link;
+ *head = ffs(ior->arm.head) - 1;
+ *proto_evo = ior->arm.proto_evo;
+ ret = 0;
+done:
+ nvkm_uoutp_unlock(uoutp);
return ret;
}
@@ -549,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_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_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);
@@ -599,6 +598,7 @@ nvkm_uoutp_del(struct nvif_outp_priv *uoutp)
static const struct nvif_outp_impl
nvkm_uoutp_impl = {
.del = nvkm_uoutp_del,
+ .inherit = nvkm_uoutp_inherit,
};
static void *
--
2.41.0
More information about the Nouveau
mailing list