- transition from "ioctl" interface Signed-off-by: Ben Skeggs <bskeggs@xxxxxxxxxx> --- .../gpu/drm/nouveau/include/nvif/driverif.h | 8 ++++ drivers/gpu/drm/nouveau/include/nvif/if0012.h | 11 ----- drivers/gpu/drm/nouveau/include/nvif/outp.h | 6 --- drivers/gpu/drm/nouveau/nouveau_connector.c | 6 +-- drivers/gpu/drm/nouveau/nouveau_dp.c | 2 +- drivers/gpu/drm/nouveau/nvif/outp.c | 21 ++------- .../gpu/drm/nouveau/nvkm/engine/disp/uoutp.c | 47 ++++++++++++++----- 7 files changed, 53 insertions(+), 48 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvif/driverif.h b/drivers/gpu/drm/nouveau/include/nvif/driverif.h index 8d00ed58323f..fd05065374fe 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/driverif.h +++ b/drivers/gpu/drm/nouveau/include/nvif/driverif.h @@ -244,6 +244,12 @@ struct nvif_conn_impl { const struct nvif_event_impl **, struct nvif_event_priv **); }; +enum nvif_outp_detect_status { + NVIF_OUTP_DETECT_NOT_PRESENT, + NVIF_OUTP_DETECT_PRESENT, + NVIF_OUTP_DETECT_UNKNOWN, +}; + struct nvif_outp_impl { void (*del)(struct nvif_outp_priv *); @@ -267,6 +273,8 @@ struct nvif_outp_impl { u8 ddc; u8 conn; + int (*detect)(struct nvif_outp_priv *, enum nvif_outp_detect_status *); + 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 d1e2f0ff8965..c0c13cb64994 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_DETECT 0x00 #define NVIF_OUTP_V0_EDID_GET 0x01 #define NVIF_OUTP_V0_INHERIT 0x10 @@ -33,16 +32,6 @@ #define NVIF_OUTP_V0_DP_MST_ID_PUT 0x77 #define NVIF_OUTP_V0_DP_MST_VCPI 0x78 -union nvif_outp_detect_args { - struct nvif_outp_detect_v0 { - __u8 version; -#define NVIF_OUTP_DETECT_V0_NOT_PRESENT 0x00 -#define NVIF_OUTP_DETECT_V0_PRESENT 0x01 -#define NVIF_OUTP_DETECT_V0_UNKNOWN 0x02 - __u8 status; - } v0; -}; - union nvif_outp_edid_get_args { struct nvif_outp_edid_get_v0 { __u8 version; diff --git a/drivers/gpu/drm/nouveau/include/nvif/outp.h b/drivers/gpu/drm/nouveau/include/nvif/outp.h index 56bfbc41a576..7a64a7d2ac97 100644 --- a/drivers/gpu/drm/nouveau/include/nvif/outp.h +++ b/drivers/gpu/drm/nouveau/include/nvif/outp.h @@ -21,12 +21,6 @@ struct nvif_outp { int nvif_outp_ctor(struct nvif_disp *, const char *name, int id, struct nvif_outp *); void nvif_outp_dtor(struct nvif_outp *); -enum nvif_outp_detect_status { - NOT_PRESENT, - PRESENT, - UNKNOWN, -}; - enum nvif_outp_detect_status nvif_outp_detect(struct nvif_outp *); int nvif_outp_edid_get(struct nvif_outp *, u8 **pedid); diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index b1bd8264b703..3063ef792023 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -434,11 +434,11 @@ nouveau_connector_ddc_detect(struct drm_connector *connector) } else { status = nvif_outp_detect(&nv_encoder->outp); switch (status) { - case PRESENT: + case NVIF_OUTP_DETECT_PRESENT: return nv_encoder; - case NOT_PRESENT: + case NVIF_OUTP_DETECT_NOT_PRESENT: continue; - case UNKNOWN: + case NVIF_OUTP_DETECT_UNKNOWN: break; default: WARN_ON(1); diff --git a/drivers/gpu/drm/nouveau/nouveau_dp.c b/drivers/gpu/drm/nouveau/nouveau_dp.c index a72c45809484..cf196af96609 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dp.c +++ b/drivers/gpu/drm/nouveau/nouveau_dp.c @@ -256,7 +256,7 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector, } hpd = nvif_outp_detect(&nv_encoder->outp); - if (hpd == NOT_PRESENT) { + if (hpd == NVIF_OUTP_DETECT_NOT_PRESENT) { nvif_outp_dp_aux_pwr(&nv_encoder->outp, false); goto out; } diff --git a/drivers/gpu/drm/nouveau/nvif/outp.c b/drivers/gpu/drm/nouveau/nvif/outp.c index a8012a71a50c..b704886c1bb6 100644 --- a/drivers/gpu/drm/nouveau/nvif/outp.c +++ b/drivers/gpu/drm/nouveau/nvif/outp.c @@ -467,26 +467,15 @@ nvif_outp_edid_get(struct nvif_outp *outp, u8 **pedid) enum nvif_outp_detect_status nvif_outp_detect(struct nvif_outp *outp) { - struct nvif_outp_detect_v0 args; + enum nvif_outp_detect_status status; int ret; - args.version = 0; - - ret = nvif_mthd(&outp->object, NVIF_OUTP_V0_DETECT, &args, sizeof(args)); - NVIF_ERRON(ret, &outp->object, "[DETECT] status:%02x", args.status); + ret = outp->impl->detect(outp->priv, &status); + NVIF_ERRON(ret, &outp->object, "[DETECT] status:%02x", status); if (ret) - return UNKNOWN; - - switch (args.status) { - case NVIF_OUTP_DETECT_V0_NOT_PRESENT: return NOT_PRESENT; - case NVIF_OUTP_DETECT_V0_PRESENT: return PRESENT; - case NVIF_OUTP_DETECT_V0_UNKNOWN: return UNKNOWN; - default: - WARN_ON(1); - break; - } + return NVIF_OUTP_DETECT_UNKNOWN; - return UNKNOWN; + return status; } void diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c index b585b781e928..2324549787b6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/uoutp.c @@ -35,6 +35,31 @@ struct nvif_outp_priv { struct nvif_outp_impl impl; }; +static inline void +nvkm_uoutp_unlock(struct nvif_outp_priv *uoutp) +{ + mutex_unlock(&uoutp->outp->disp->super.mutex); +} + +static inline void +nvkm_uoutp_lock(struct nvif_outp_priv *uoutp) +{ + mutex_lock(&uoutp->outp->disp->super.mutex); +} + +static inline int +nvkm_uoutp_lock_acquired(struct nvif_outp_priv *uoutp) +{ + nvkm_uoutp_lock(uoutp); + + if (!uoutp->outp->ior) { + nvkm_uoutp_unlock(uoutp); + return -EIO; + } + + return 0; +} + static int nvkm_uoutp_mthd_dp_mst_vcpi(struct nvkm_outp *outp, void *argv, u32 argc) { @@ -480,22 +505,20 @@ nvkm_uoutp_mthd_edid_get(struct nvkm_outp *outp, void *argv, u32 argc) } static int -nvkm_uoutp_mthd_detect(struct nvkm_outp *outp, void *argv, u32 argc) +nvkm_uoutp_detect(struct nvif_outp_priv *uoutp, enum nvif_outp_detect_status *status) { - union nvif_outp_detect_args *args = argv; + struct nvkm_outp *outp = uoutp->outp; int ret; - if (argc != sizeof(args->v0) || args->v0.version != 0) - return -ENOSYS; - if (!outp->func->detect) - return -EINVAL; - + nvkm_uoutp_lock(uoutp); ret = outp->func->detect(outp); + nvkm_uoutp_unlock(uoutp); + switch (ret) { - case 0: args->v0.status = NVIF_OUTP_DETECT_V0_NOT_PRESENT; break; - case 1: args->v0.status = NVIF_OUTP_DETECT_V0_PRESENT; break; + case 0: *status = NVIF_OUTP_DETECT_NOT_PRESENT; break; + case 1: *status = NVIF_OUTP_DETECT_PRESENT; break; default: - args->v0.status = NVIF_OUTP_DETECT_V0_UNKNOWN; + *status = NVIF_OUTP_DETECT_UNKNOWN; break; } @@ -528,7 +551,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_DETECT : return nvkm_uoutp_mthd_detect (outp, argv, argc); 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); @@ -627,6 +649,9 @@ nvkm_uoutp_new(struct nvkm_disp *disp, u8 id, const struct nvif_outp_impl **pimp uoutp->impl = nvkm_uoutp_impl; uoutp->impl.id = id; + if (outp->func->detect) + uoutp->impl.detect = nvkm_uoutp_detect; + switch (outp->info.type) { case DCB_OUTPUT_ANALOG: uoutp->impl.type = NVIF_OUTP_DAC; -- 2.41.0